Radar · Solidity · Archive · Week 37 · Sep 7 – 13, 2026
Memory Byte Array Element Delete Clears Whole Word Bug
Worth knowingcompiler
- What changed
- The code generator now zeroes only the targeted byte when
deleteis applied to an element of a memory‑backedbytesarray, instead of clearing the entire 32‑byte word. - Production impact
- The source does not say.
- Try it
- Compile a contract that deletes a single element of a memory
bytesarray and verify that only that byte is cleared. - Source
- github.com/argotorg/solidity/releases/tag/v0.8.37
Understand it, then run it
Run it now
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.37;
// This contract demonstrates that delete on a memory bytes array element
// clears only the targeted byte, not the whole 32‑byte word.
contract Main {
function clearByte(uint index) external pure returns (bytes memory) {
bytes memory data = new bytes(5);
// set all bytes to 0xFF for visibility
for (uint i = 0; i < data.length; i++) {
data[i] = 0xFF;
}
// delete the element at `index`
delete data[index];
return data;
}
}
Tests
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.37;
import "./main.sol";
contract MainTest {
Main main;
constructor() {
main = new Main();
}
function test_singleByteCleared() public {
bytes memory result = main.clearByte(2);
// bytes[2] should be 0x00, others remain 0xFF
require(result[2] == 0x00, "byte not cleared");
require(result[0] == 0xFF, "other byte altered");
require(result[1] == 0xFF, "other byte altered");
require(result[3] == 0xFF, "other byte altered");
require(result[4] == 0xFF, "other byte altered");
}
}
The test report when we ran it on Solidity 0.8.37 (solc)
1 of 1 tests passed.
- test_singleByteCleared28,200 gas
- MainTest: 1,355 bytes of bytecode, deployed for 372,262 gas
solc 0.8.37 · prague
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed