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

Fixed a warning that was coming up for vector<unsigned char> fill #158

Merged
merged 1 commit into from
Aug 4, 2024

Conversation

mxaddict
Copy link
Collaborator

This fixes a warning during build:

In file included from /usr/include/c++/14.1.1/string:51,
                 from ./crypto/sha256.h:10,
                 from ./hash.h:12,
                 from ./blsct/arith/mcl/mcl_scalar.h:15,
                 from ./blsct/arith/mcl/mcl_g1point.h:12,
                 from ./blsct/arith/mcl/mcl.h:12,
                 from ./blsct/double_public_key.h:8,
                 from ./addresstype.h:9,
                 from ./wallet/wallet.h:9,
                 from wallet/test/wallet_tests.cpp:5:
In function ‘constexpr typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = unsigned char*; _Tp = int]’,
    inlined from ‘constexpr void std::__fill_a1(__gnu_cxx::__normal_iterator<_Iterator, _Container>, __gnu_cxx::__normal_iterator<_Iterator, _Container>, const _Tp&) [with _Ite = unsigned char*; _Cont = vector<unsigned char>; _Tp = int]’ at /usr/include/c++/14.1.1/bits/stl_algobase.h:981:21,
    inlined from ‘constexpr void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = __gnu_cxx::__normal_iterator<unsigned char*, vector<unsigned char> >; _Tp = int]’ at /usr/include/c++/14.1.1/bits/stl_algobase.h:998:21,
    inlined from ‘constexpr void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = __gnu_cxx::__normal_iterator<unsigned char*, vector<unsigned char> >; _Tp = int]’ at /usr/include/c++/14.1.1/bits/stl_algobase.h:1029:20,
    inlined from ‘void wallet::wallet_tests::PollutePubKey(CPubKey&)’ at wallet/test/wallet_tests.cpp:502:14:
/usr/include/c++/14.1.1/bits/stl_algobase.h:952:18: warning: ‘void* __builtin_memset(void*, int, long unsigned int)’ specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
  952 |         *__first = __tmp;
      |         ~~~~~~~~~^~~~~~~

@mxaddict
Copy link
Collaborator Author

This PR should be ready to review/merge

@gogoex
Copy link
Collaborator

gogoex commented Aug 1, 2024

Just out of curiosity, does the warning disappear if you:

  • only add the assert line at the beginning and doesn't change anything and/or
  • typecast 0 in the fill method to unsigned char i.e. static_cast<unsigned char>(0)
    ?

@mxaddict
Copy link
Collaborator Author

mxaddict commented Aug 2, 2024

Just out of curiosity, does the warning disappear if you:

  • only add the assert line at the beginning and doesn't change anything and/or
  • typecast 0 in the fill method to unsigned char i.e. static_cast<unsigned char>(0)
    ?

I'm not 100% sure, but the fix I've implemented is from upstream bitcoin repo 😄

@gogoex
Copy link
Collaborator

gogoex commented Aug 3, 2024

Just out of curiosity, does the warning disappear if you:

  • only add the assert line at the beginning and doesn't change anything and/or
  • typecast 0 in the fill method to unsigned char i.e. static_cast<unsigned char>(0)
    ?

I'm not 100% sure, but the fix I've implemented is from upstream bitcoin repo 😄

Ah. I see 😁

Copy link
Collaborator

@gogoex gogoex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change is reasonable.

@aguycalled aguycalled merged commit d0a3345 into nav-io:master Aug 4, 2024
5 of 16 checks passed
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.

3 participants