Skip to content

Compile error with GCC 14.2 and -D_GLIBCXX_DEBUG #31515

Closed
@hebasto

Description

The master branch @ b042c4f fails to compile with GCC 14.2 and -D_GLIBCXX_DEBUG:

$ cmake -B build -DCMAKE_CXX_FLAGS="-D_GLIBCXX_DEBUG"
$ cmake --build build --target bitcoind
[4/6] Building CXX object src/CMakeFiles/bitcoin_consensus.dir/pubkey.cpp.o
FAILED: src/CMakeFiles/bitcoin_consensus.dir/pubkey.cpp.o 
/usr/bin/ccache /usr/bin/c++  -I/home/hebasto/git/bitcoin/build/src -I/home/hebasto/git/bitcoin/src -I/home/hebasto/git/bitcoin/src/secp256k1/include -D_GLIBCXX_DEBUG -O2 -g -std=c++20 -fPIC -fno-extended-identifiers -fdebug-prefix-map=/home/hebasto/git/bitcoin/src=. -fmacro-prefix-map=/home/hebasto/git/bitcoin/src=. -fstack-reuse=none -Wall -Wextra -Wformat -Wformat-security -Wvla -Wredundant-decls -Wdate-time -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wbidi-chars=any -Wundef -Wno-unused-parameter -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection -MD -MT src/CMakeFiles/bitcoin_consensus.dir/pubkey.cpp.o -MF src/CMakeFiles/bitcoin_consensus.dir/pubkey.cpp.o.d -o src/CMakeFiles/bitcoin_consensus.dir/pubkey.cpp.o -c /home/hebasto/git/bitcoin/src/pubkey.cpp 
In file included from /usr/include/c++/14/debug/debug.h:90,
                 from /usr/include/c++/14/bits/stl_algobase.h:69,
                 from /usr/include/c++/14/string:51,
                 from /home/hebasto/git/bitcoin/src/crypto/sha256.h:10,
                 from /home/hebasto/git/bitcoin/src/hash.h:12,
                 from /home/hebasto/git/bitcoin/src/pubkey.h:10,
                 from /home/hebasto/git/bitcoin/src/pubkey.cpp:6:
/home/hebasto/git/bitcoin/src/pubkey.cpp:195:116:   in ‘constexpr’ expansion of ‘std::span<const unsigned char>(util::hex_literals::operator""_hex_u8<util::detail::Hex<65>{std::array<std::byte, 32>{std::__array_traits<std::byte, 32>::_Type{(std::byte)80, (std::byte)146, (std::byte)155, (std::byte)116, (std::byte)193, (std::byte)160, (std::byte)73, (std::byte)84, (std::byte)183, (std::byte)139, (std::byte)75, (std::byte)96, (std::byte)53, (std::byte)233, (std::byte)122, (std::byte)94, (std::byte)7, (std::byte)138, (std::byte)90, (std::byte)15, (std::byte)40, (std::byte)236, (std::byte)150, (std::byte)213, (std::byte)71, (std::byte)191, (std::byte)238, (std::byte)154, (std::byte)206, (std::byte)128, (std::byte)58, (std::byte)192}}}>())’
/usr/include/c++/14/span:202:57:   in ‘constexpr’ expansion of ‘((std::span<const unsigned char>*)this)->std::span<const unsigned char>::span<const unsigned char*>((& __arr)->std::array<unsigned char, 32>::data(), 32)’
/usr/include/c++/14/span:165:11: error: ‘__builtin_expect(((long int)(! __gnu_debug::__valid_range<const unsigned char*>(__first, (__first + ((sizetype)__count))))), 0)’ is not a constant expression
  165 |           __glibcxx_requires_valid_range(__first, __first + __count);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.

The issue was introduced in 50bc017 from #30377.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions