Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Workaround GCC 12 warning at -O3 #691

Merged
merged 1 commit into from
Aug 22, 2023
Merged

test: Workaround GCC 12 warning at -O3 #691

merged 1 commit into from
Aug 22, 2023

Conversation

chfast
Copy link
Member

@chfast chfast commented Aug 22, 2023

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.

@chfast chfast requested review from gumb0 and rodiazet August 22, 2023 09:37
@codecov
Copy link

codecov bot commented Aug 22, 2023

Codecov Report

Merging #691 (8113d01) into master (0068ddf) will not change coverage.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #691   +/-   ##
=======================================
  Coverage   97.53%   97.53%           
=======================================
  Files          86       86           
  Lines        8236     8236           
=======================================
  Hits         8033     8033           
  Misses        203      203           
Flag Coverage Δ
blockchaintests 62.71% <ø> (ø)
statetests 73.94% <ø> (ø)
statetests-silkpre 23.18% <0.00%> (ø)
unittests 95.12% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
test/unittests/state_mpt_hash_test.cpp 99.04% <100.00%> (ø)

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.
@chfast chfast merged commit 35f4141 into master Aug 22, 2023
@chfast chfast deleted the gcc12_warning branch August 22, 2023 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants