Skip to content

Commit 7353336

Browse files
committed
test: Workaround GCC 12 warning at -O3
When compiling `code = {0x00}` with GCC 12 -O3 it detects a false positive buffer overflow and gives a warning. Workaround it by using explicit `code = bytes{0x00}`. ``` /usr/include/c++/12/bits/char_traits.h:268:23: error: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ accessing 9223372036854775810 or more bytes at offsets -4611686018427387902 and [-4611686018427387903, 4611686018427387904] may overlap up to 9223372036854775813 bytes at offset -3 [-Werror=restrict] 268 | __builtin_memcpy(__s1, __s2, __n * sizeof(char_type)); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` The warning is gone in GCC 13.
1 parent 4b2db8b commit 7353336

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

test/unittests/state_mpt_hash_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ TEST(state_mpt_hash, two_accounts)
4545
Account acc2;
4646
acc2.nonce = 1;
4747
acc2.balance = -2_u256;
48-
acc2.code = {0x00};
48+
acc2.code = bytes{0x00}; // Note: `= {0x00}` causes GCC 12 warning at -O3.
4949
acc2.storage[0x01_bytes32] = {0xfe_bytes32};
5050
acc2.storage[0x02_bytes32] = {0xfd_bytes32};
5151
accounts[0x01_address] = acc2;

0 commit comments

Comments
 (0)