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

Compile Warnings [-Wstringop-overread] #14

Open
sats0k opened this issue Nov 14, 2021 · 4 comments
Open

Compile Warnings [-Wstringop-overread] #14

sats0k opened this issue Nov 14, 2021 · 4 comments

Comments

@sats0k
Copy link
Contributor

sats0k commented Nov 14, 2021

    inlined from ‘std::string CBase58Data::ToString() const’ at src/base58.h:218:19:
/usr/include/c++/11.1.0/bits/stl_algobase.h:431:30: warning: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ reading 1 or more bytes from a region of size 0 [-Wstringop-overread]
  431 |             __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
      |             ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11.1.0/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
                 from /usr/include/c++/11.1.0/bits/allocator.h:46,
                 from /usr/include/c++/11.1.0/unordered_map:40,
                 from /usr/include/c++/11.1.0/functional:61,
                 from /usr/include/c++/11.1.0/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11.1.0/algorithm:74,
                 from /usr/include/qt/QtCore/qglobal.h:142,
                 from /usr/include/qt/QtGui/qtguiglobal.h:43,
                 from /usr/include/qt/QtGui/qfont.h:43,
                 from /usr/include/qt/QtGui/QFont:1,
                 from src/qt/addresstablemodel.cpp:1:
/usr/include/c++/11.1.0/ext/new_allocator.h: In member function ‘std::string CBase58Data::ToString() const’:
/usr/include/c++/11.1.0/ext/new_allocator.h:121:48: note: at offset 1 into source object of size 1 allocated by ‘operator new’
  121 |         return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
      |                                  ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~

There are many of this warnings when compiling the wallet.
I made test with -O3 and -Ofast parameters most of the warnings are gone but remaining two more of them.

@ghostlander
Copy link
Owner

GCC 9 doesn't produce any warnings. I haven't checked with 10 or 11 yet.

@sats0k
Copy link
Contributor Author

sats0k commented Nov 14, 2021

These warnings appears on GCC 11.1.0

@sats0k
Copy link
Contributor Author

sats0k commented Dec 28, 2021

Finally compiling with -Os all the warnings are gone.
These warnings are false positive according to GCC patch
and should be corrected at GCC 12, i have not checked yet.

@sats0k
Copy link
Contributor Author

sats0k commented Jan 8, 2022

Testing GCC 12 the warnings became to [-Warray-bounds]

inlined from ‘std::string CBase58Data::ToString() const’ at src/base58.h:218:19:
/home/k0stas/gcc/include/c++/12.0.0/bits/stl_algobase.h:431:30: warning: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ offset 1 is out of the bounds [0, 1] [-Warray-bounds]
  431 |             __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
      |             ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/k0stas/gcc/include/c++/12.0.0/bits/stl_algobase.h:431:30: warning: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ offset 1 is out of the bounds [0, 1] [-Warray-bounds]

resizing the vector all goes well
commit 4163e97

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

No branches or pull requests

2 participants