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:

    $ cmake -B build -DAPPEND_CPPFLAGS="-D_GLIBCXX_DEBUG"
    -- The CXX compiler identification is GNU 13.3.0
    <snip>
    $ cmake --build build
    [2/10] Building CXX object src/CMakeFiles/bitcoin_common.dir/musig.cpp.o
    FAILED: src/CMakeFiles/bitcoin_common.dir/musig.cpp.o 
    /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
    In file included from /usr/include/c++/13/debug/stl_iterator.h:32,
                     from /usr/include/c++/13/bits/stl_iterator.h:3003,
                     from /usr/include/c++/13/string:48,
                     from ../src/crypto/sha256.h:10,
                     from ../src/hash.h:12,
                     from ../src/pubkey.h:10,
                     from ../src/musig.h:8,
                     from ../src/musig.cpp:5:
    ../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}}}>())’
    /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)’
    /usr/include/c++/13/span:167:4:   in ‘constexpr’ expansion of ‘__gnu_debug::__valid_range<const unsigned char*>(__first, (__first + ((sizetype)__count)))’
    /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()))’
    /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()))’
    /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()))’
    /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
      143 |     { return __ptr == 0; }
          |              ~~~~~~^~~~
    [3/10] Building CXX object src/CMakeFiles/bitcoin_common.dir/script/descriptor.cpp.o
    FAILED: src/CMakeFiles/bitcoin_common.dir/script/descriptor.cpp.o 
    /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
    In file included from /usr/include/c++/13/debug/stl_iterator.h:32,
                     from /usr/include/c++/13/bits/stl_iterator.h:3003,
                     from /usr/include/c++/13/string:48,
                     from ../src/crypto/sha256.h:10,
                     from ../src/hash.h:12,
                     from ../src/pubkey.h:10,
                     from ../src/addresstype.h:9,
                     from ../src/outputtype.h:9,
                     from ../src/script/descriptor.h:8,
                     from ../src/script/descriptor.cpp:5:
    ../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}}}>())’
    /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)’
    /usr/include/c++/13/span:167:4:   in ‘constexpr’ expansion of ‘__gnu_debug::__valid_range<const unsigned char*>(__first, (__first + ((sizetype)__count)))’
    /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()))’
    /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()))’
    /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()))’
    /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
      143 |     { return __ptr == 0; }
          |              ~~~~~~^~~~
    ninja: 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

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

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

    <!--021abf342d371248e50ceaed478a90ca-->

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  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?

    
    
    
    
        ci: Re-enable DEBUG=1 in centos task
        
        This reverts the workaround in commit fa079538e32d20aec6786c93e1117da1e8ea0cab, as it is no longer needed.
    
    diff --git a/ci/test/00_setup_env_native_centos.sh b/ci/test/00_setup_env_native_centos.sh
    index 25b9923dc7..94002b6349 100755
    --- a/ci/test/00_setup_env_native_centos.sh
    +++ b/ci/test/00_setup_env_native_centos.sh
    @@ -10,11 +10,11 @@ export CONTAINER_NAME=ci_native_centos
     export CI_IMAGE_NAME_TAG="quay.io/centos/centos:stream10"
     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"
     export PIP_PACKAGES="pyzmq"
    +export DEP_OPTS="DEBUG=1"
     export GOAL="install"
     export BITCOIN_CONFIG="\
      -DWITH_ZMQ=ON \
      -DBUILD_GUI=ON \
      -DREDUCE_EXPORTS=ON \
    - -DAPPEND_CPPFLAGS='-D_GLIBCXX_ASSERTIONS' \
      -DCMAKE_BUILD_TYPE=Debug \
     "
    

    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?

        ci: Re-enable DEBUG=1 in centos task
        
        This reverts the workaround in commit fa079538e32d20aec6786c93e1117da1e8ea0cab, as it is no longer needed.
    
    diff --git a/ci/test/00_setup_env_native_centos.sh b/ci/test/00_setup_env_native_centos.sh
    index 25b9923dc7..94002b6349 100755
    --- a/ci/test/00_setup_env_native_centos.sh
    +++ b/ci/test/00_setup_env_native_centos.sh
    @@ -10,11 +10,11 @@ export CONTAINER_NAME=ci_native_centos
     export CI_IMAGE_NAME_TAG="quay.io/centos/centos:stream10"
     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"
     export PIP_PACKAGES="pyzmq"
    +export DEP_OPTS="DEBUG=1"
     export GOAL="install"
     export BITCOIN_CONFIG="\
      -DWITH_ZMQ=ON \
      -DBUILD_GUI=ON \
      -DREDUCE_EXPORTS=ON \
    - -DAPPEND_CPPFLAGS='-D_GLIBCXX_ASSERTIONS' \
      -DCMAKE_BUILD_TYPE=Debug \
     "
    

    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

  9. fanquake merged this on Aug 6, 2025
  10. fanquake closed this on Aug 6, 2025

  11. hebasto deleted the branch on Aug 6, 2025
  12. sedited referenced this in commit b98d982d79 on Aug 7, 2025
  13. stringintech referenced this in commit 71275a1b5e on Aug 17, 2025
  14. yuvicc referenced this in commit 22f55cf11d on Aug 26, 2025
  15. bug-castercv502 referenced this in commit 4aa5572aea on Sep 28, 2025
  16. stickies-v referenced this in commit a19c56cd7c on Nov 4, 2025
  17. Kino1994 referenced this in commit 6964345b5a on Jun 28, 2026
  18. BigcoinBGC referenced this in commit 565d4f8c17 on Jun 30, 2026
  19. bitcoin locked this on Aug 6, 2026

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: 2026-08-24 13:51 UTC

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