refactor: Use immediate lambda to work around GCC bug 117966 #33113

pull hebasto wants to merge 2 commits into bitcoin:master from hebasto:250801-musig-gcc changing 2 files +7 −2
  1. hebasto commented at 11:16 am on August 1, 2025: member

    This PR is a follow-up to the recently merged #31244, and provides a workaround for affected GCC compilers, similar to #31493.

    Without this workaround, building the master branch using GCC 13 or 14 with the -D_GLIBCXX_DEBUG flag fails with the following error:

     0$ cmake -B build -DAPPEND_CPPFLAGS="-D_GLIBCXX_DEBUG"
     1-- The CXX compiler identification is GNU 13.3.0
     2<snip>
     3$ cmake --build build
     4[2/10] Building CXX object src/CMakeFiles/bitcoin_common.dir/musig.cpp.o
     5FAILED: src/CMakeFiles/bitcoin_common.dir/musig.cpp.o 
     6/usr/bin/ccache /usr/bin/c++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_NO_CXX98_FUNCTION_BASE -I/home/hebasto/dev/bitcoin/build/src -I/home/hebasto/dev/bitcoin/src -I/home/hebasto/dev/bitcoin/src/univalue/include -I/home/hebasto/dev/bitcoin/src/secp256k1/include -O2 -g -std=c++20 -fPIC -fno-extended-identifiers -fdebug-prefix-map=/home/hebasto/dev/bitcoin/src=. -fmacro-prefix-map=/home/hebasto/dev/bitcoin/src=. -fstack-reuse=none -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection -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 -MD -MT src/CMakeFiles/bitcoin_common.dir/musig.cpp.o -MF src/CMakeFiles/bitcoin_common.dir/musig.cpp.o.d -o src/CMakeFiles/bitcoin_common.dir/musig.cpp.o -c /home/hebasto/dev/bitcoin/src/musig.cpp -D_GLIBCXX_DEBUG
     7In file included from /usr/include/c++/13/debug/stl_iterator.h:32,
     8                 from /usr/include/c++/13/bits/stl_iterator.h:3003,
     9                 from /usr/include/c++/13/string:48,
    10                 from ../src/crypto/sha256.h:10,
    11                 from ../src/hash.h:12,
    12                 from ../src/pubkey.h:10,
    13                 from ../src/musig.h:8,
    14                 from ../src/musig.cpp:5:
    15../src/musig.h:17:108:   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)134, (std::byte)128, (std::byte)135, (std::byte)202, (std::byte)2, (std::byte)166, (std::byte)249, (std::byte)116, (std::byte)196, (std::byte)89, (std::byte)137, (std::byte)36, (std::byte)195, (std::byte)107, (std::byte)87, (std::byte)118, (std::byte)45, (std::byte)50, (std::byte)203, (std::byte)69, (std::byte)113, (std::byte)113, (std::byte)103, (std::byte)227, (std::byte)0, (std::byte)98, (std::byte)44, (std::byte)113, (std::byte)103, (std::byte)227, (std::byte)137, (std::byte)101}}}>())
    16/usr/include/c++/13/span:204: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)
    17/usr/include/c++/13/span:167:4:   in constexpr expansion of __gnu_debug::__valid_range<const unsigned char*>(__first, (__first + ((sizetype)__count)))
    18/usr/include/c++/13/debug/helper_functions.h:267:44:   in constexpr expansion of __gnu_debug::__valid_range_aux<const unsigned char*>(__first, __last, (_Integral(), _Integral()))
    19/usr/include/c++/13/debug/helper_functions.h:197:44:   in constexpr expansion of __gnu_debug::__valid_range_aux<const unsigned char*>(__first, __last, (std::__iterator_category<const unsigned char*>(__first), std::iterator_traits<const unsigned char*>::iterator_category()))
    20/usr/include/c++/13/debug/helper_functions.h:183:44:   in constexpr expansion of __gnu_debug::__valid_range_aux<const unsigned char*>(__first, __last, (std::input_iterator_tag(), std::input_iterator_tag()))
    21/usr/include/c++/13/debug/helper_functions.h:143:20: error: (((const unsigned char*)(&<anonymous>.std::array<unsigned char, 32>::_M_elems)) == 0) is not a constant expression
    22  143 |     { return __ptr == 0; }
    23      |              ~~~~~~^~~~
    24[3/10] Building CXX object src/CMakeFiles/bitcoin_common.dir/script/descriptor.cpp.o
    25FAILED: src/CMakeFiles/bitcoin_common.dir/script/descriptor.cpp.o 
    26/usr/bin/ccache /usr/bin/c++ -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_NO_CXX98_FUNCTION_BASE -I/home/hebasto/dev/bitcoin/build/src -I/home/hebasto/dev/bitcoin/src -I/home/hebasto/dev/bitcoin/src/univalue/include -I/home/hebasto/dev/bitcoin/src/secp256k1/include -O2 -g -std=c++20 -fPIC -fno-extended-identifiers -fdebug-prefix-map=/home/hebasto/dev/bitcoin/src=. -fmacro-prefix-map=/home/hebasto/dev/bitcoin/src=. -fstack-reuse=none -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection -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 -MD -MT src/CMakeFiles/bitcoin_common.dir/script/descriptor.cpp.o -MF src/CMakeFiles/bitcoin_common.dir/script/descriptor.cpp.o.d -o src/CMakeFiles/bitcoin_common.dir/script/descriptor.cpp.o -c /home/hebasto/dev/bitcoin/src/script/descriptor.cpp -D_GLIBCXX_DEBUG
    27In file included from /usr/include/c++/13/debug/stl_iterator.h:32,
    28                 from /usr/include/c++/13/bits/stl_iterator.h:3003,
    29                 from /usr/include/c++/13/string:48,
    30                 from ../src/crypto/sha256.h:10,
    31                 from ../src/hash.h:12,
    32                 from ../src/pubkey.h:10,
    33                 from ../src/addresstype.h:9,
    34                 from ../src/outputtype.h:9,
    35                 from ../src/script/descriptor.h:8,
    36                 from ../src/script/descriptor.cpp:5:
    37../src/musig.h:17:108:   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)134, (std::byte)128, (std::byte)135, (std::byte)202, (std::byte)2, (std::byte)166, (std::byte)249, (std::byte)116, (std::byte)196, (std::byte)89, (std::byte)137, (std::byte)36, (std::byte)195, (std::byte)107, (std::byte)87, (std::byte)118, (std::byte)45, (std::byte)50, (std::byte)203, (std::byte)69, (std::byte)113, (std::byte)113, (std::byte)103, (std::byte)227, (std::byte)0, (std::byte)98, (std::byte)44, (std::byte)113, (std::byte)103, (std::byte)227, (std::byte)137, (std::byte)101}}}>())
    38/usr/include/c++/13/span:204: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)
    39/usr/include/c++/13/span:167:4:   in constexpr expansion of __gnu_debug::__valid_range<const unsigned char*>(__first, (__first + ((sizetype)__count)))
    40/usr/include/c++/13/debug/helper_functions.h:267:44:   in constexpr expansion of __gnu_debug::__valid_range_aux<const unsigned char*>(__first, __last, (_Integral(), _Integral()))
    41/usr/include/c++/13/debug/helper_functions.h:197:44:   in constexpr expansion of __gnu_debug::__valid_range_aux<const unsigned char*>(__first, __last, (std::__iterator_category<const unsigned char*>(__first), std::iterator_traits<const unsigned char*>::iterator_category()))
    42/usr/include/c++/13/debug/helper_functions.h:183:44:   in constexpr expansion of __gnu_debug::__valid_range_aux<const unsigned char*>(__first, __last, (std::input_iterator_tag(), std::input_iterator_tag()))
    43/usr/include/c++/13/debug/helper_functions.h:143:20: error: (((const unsigned char*)(&<anonymous>.std::array<unsigned char, 32>::_M_elems)) == 0) is not a constant expression
    44  143 |     { return __ptr == 0; }
    45      |              ~~~~~~^~~~
    46ninja: build stopped: subcommand failed.
    
  2. refactor: Use immediate lambda to work around GCC bug 117966 a7bafb3e05
  3. hebasto added the label Refactoring on Aug 1, 2025
  4. DrahtBot commented at 11:16 am on August 1, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33113.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK achow101

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  5. maflcko commented at 11:32 am on August 1, 2025: member

    Seems fine, but it can’t hurt to enforce it in CI again?

     0
     1
     2
     3
     4    ci: Re-enable DEBUG=1 in centos task
     5    
     6    This reverts the workaround in commit fa079538e32d20aec6786c93e1117da1e8ea0cab, as it is no longer needed.
     7
     8diff --git a/ci/test/00_setup_env_native_centos.sh b/ci/test/00_setup_env_native_centos.sh
     9index 25b9923dc7..94002b6349 100755
    10--- a/ci/test/00_setup_env_native_centos.sh
    11+++ b/ci/test/00_setup_env_native_centos.sh
    12@@ -10,11 +10,11 @@ export CONTAINER_NAME=ci_native_centos
    13 export CI_IMAGE_NAME_TAG="quay.io/centos/centos:stream10"
    14 export CI_BASE_PACKAGES="gcc-c++ glibc-devel libstdc++-devel ccache make ninja-build git python3 python3-pip which patch xz procps-ng ksh rsync coreutils bison e2fsprogs cmake"
    15 export PIP_PACKAGES="pyzmq"
    16+export DEP_OPTS="DEBUG=1"
    17 export GOAL="install"
    18 export BITCOIN_CONFIG="\
    19  -DWITH_ZMQ=ON \
    20  -DBUILD_GUI=ON \
    21  -DREDUCE_EXPORTS=ON \
    22- -DAPPEND_CPPFLAGS='-D_GLIBCXX_ASSERTIONS' \
    23  -DCMAKE_BUILD_TYPE=Debug \
    24 "
    

    Extra runtime seems to be 3 minutes, which seems fine?

  6. ci: Re-enable DEBUG=1 in centos task
    This reverts the workaround in commit fa079538e32d20aec6786c93e1117da1e8ea0cab, as it is no longer needed.
    c7a24c3052
  7. hebasto commented at 4:20 pm on August 1, 2025: member

    Seems fine, but it can’t hurt to enforce it in CI again?

     0    ci: Re-enable DEBUG=1 in centos task
     1    
     2    This reverts the workaround in commit fa079538e32d20aec6786c93e1117da1e8ea0cab, as it is no longer needed.
     3
     4diff --git a/ci/test/00_setup_env_native_centos.sh b/ci/test/00_setup_env_native_centos.sh
     5index 25b9923dc7..94002b6349 100755
     6--- a/ci/test/00_setup_env_native_centos.sh
     7+++ b/ci/test/00_setup_env_native_centos.sh
     8@@ -10,11 +10,11 @@ export CONTAINER_NAME=ci_native_centos
     9 export CI_IMAGE_NAME_TAG="quay.io/centos/centos:stream10"
    10 export CI_BASE_PACKAGES="gcc-c++ glibc-devel libstdc++-devel ccache make ninja-build git python3 python3-pip which patch xz procps-ng ksh rsync coreutils bison e2fsprogs cmake"
    11 export PIP_PACKAGES="pyzmq"
    12+export DEP_OPTS="DEBUG=1"
    13 export GOAL="install"
    14 export BITCOIN_CONFIG="\
    15  -DWITH_ZMQ=ON \
    16  -DBUILD_GUI=ON \
    17  -DREDUCE_EXPORTS=ON \
    18- -DAPPEND_CPPFLAGS='-D_GLIBCXX_ASSERTIONS' \
    19  -DCMAKE_BUILD_TYPE=Debug \
    20 "
    

    Extra runtime seems to be 3 minutes, which seems fine?

    Thanks! Your changes have been added.

  8. achow101 commented at 10:49 pm on August 1, 2025: member
    ACK c7a24c3052557c4747eb8be7c40ee0a30e6b137d

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-08-04 00:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me