Skip to content

build: Boost 1.74.0 incompatible with Clang 18 #30751

Closed

Description

@fanquake

Pointed out here: #30739 (review).
Compiling with Clang 18 and Boost 1.74.0 fails:

In file included from /usr/include/boost/mpl/integral_c.hpp:32:
/usr/include/boost/mpl/aux_/integral_wrapper.hpp:73:31: error: integer value -1 is outside the valid range of values [0, 3] for the enumeration type 'udt_builtin_mixture_enum' [-Wenum-constexpr-conversion]
   73 |     typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value - 1)) ) prior;
      |                               ^
/usr/include/boost/mpl/aux_/static_cast.hpp:24:47: note: expanded from macro 'BOOST_MPL_AUX_STATIC_CAST'
   24 | #   define BOOST_MPL_AUX_STATIC_CAST(T, expr) static_cast<T>(expr)
      |                                               ^
In file included from ../../../src/test/validation_chainstatemanager_tests.cpp:8:
In file included from ../../../src/node/chainstatemanager_args.h:9:
In file included from ../../../src/validation.h:28:
In file included from ../../../src/txmempool.h:26:
In file included from /usr/include/boost/multi_index/hashed_index.hpp:38:
In file included from /usr/include/boost/multi_index/detail/node_handle.hpp:22:
In file included from /usr/include/boost/multi_index_container_fwd.hpp:18:
In file included from /usr/include/boost/multi_index/indexed_by.hpp:17:
In file included from /usr/include/boost/mpl/vector.hpp:36:
In file included from /usr/include/boost/mpl/vector/vector20.hpp:18:
In file included from /usr/include/boost/mpl/vector/vector10.hpp:18:
In file included from /usr/include/boost/mpl/vector/vector0.hpp:24:
In file included from /usr/include/boost/mpl/vector/aux_/clear.hpp:18:
In file included from /usr/include/boost/mpl/vector/aux_/vector0.hpp:22:
In file included from /usr/include/boost/mpl/vector/aux_/iterator.hpp:19:
In file included from /usr/include/boost/mpl/plus.hpp:19:
In file included from /usr/include/boost/mpl/aux_/arithmetic_op.hpp:17:
In file included from /usr/include/boost/mpl/integral_c.hpp:32:
/usr/include/boost/mpl/aux_/integral_wrapper.hpp:73:31: error: integer value -1 is outside the valid range of values [0, 3] for the enumeration type 'int_float_mixture_enum' [-Wenum-constexpr-conversion]
/usr/include/boost/mpl/aux_/static_cast.hpp:24:47: note: expanded from macro 'BOOST_MPL_AUX_STATIC_CAST'
   24 | #   define BOOST_MPL_AUX_STATIC_CAST(T, expr) static_cast<T>(expr)
      |                                               ^
2 errors generated.

The same failure does not happen with GCC (12), but may do with later versions: https://sourceware.org/bugzilla/show_bug.cgi?id=31331.

Given our documentation currently claims that Boost 1.73.0 is supported, this should be fixed in some way, the documentation updated to drop support for this version, etc. Although, it looks like part of the fix for the Boost code only landed as of 1.86.0? boostorg/mpl#69 (currently the latest release).

Activity

  1. added this to the 28.0 milestone on Aug 29, 2024
  2. maflcko commented on Aug 29, 2024

    @maflcko
    Member

    Boost code only landed as of 1.86.0?

    Ugh. I guess depends can be bumped, but using that as the minimum requirement seems a bit strict.

    While this is technically UB, is it actually observable in the compiled bitcoind?

  3. hebasto commented on Aug 29, 2024

    @hebasto
    Member

    Compiling with Clang 18 and Boost 1.74.0 fails:

    Clang 18 is used for macOS targets in Guix. Why does it work?

  4. fanquake commented on Aug 29, 2024

    @fanquake
    MemberAuthor

    Because it's not using 1.74.0? The change to Boost Numeric in 1.81.0 may be enough to avoid the issue.

  5. maflcko commented on Aug 29, 2024

    @maflcko
    Member

    Maybe the fixes can be reverted, then an objdump of bitcoind can be compared to see if it differs? If not, then it could be dead code that just happens to be compiled.

    In that case, maybe turning the error into a warning could be an alternative?

  6. justinvforvendetta commented on Sep 3, 2024

    @justinvforvendetta
    Contributor

    can confirm this issue exists with boost 1.76 as well, under the same environment.

  7. remyers commented on Sep 4, 2024

    @remyers
    Contributor

    Fwiw, I also ran across this problem (Ubuntu 20.04) while trying to run clang-tidy-diff on my code. A workaround is to just install and use clang-17.

    cmake -B build -DCMAKE_C_COMPILER=clang-17 -DCMAKE_CXX_COMPILER=clang++-17 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
    cmake --build build -j $(nproc)
    git diff HEAD~2 | ( cd ./src/ && clang-tidy-diff -p2 -path ../build -j $(nproc) )
    
  8. maflcko commented on Sep 4, 2024

    @maflcko
    Member

    Fwiw, I also ran across this problem (Ubuntu 20.04)

    I guess you also installed a different boost version, because the 1.71 boost version in Ubuntu Focal 20.04 is not supported starting with #29066 and shouldn't even pass the cmake -B command.

  9. remyers commented on Sep 4, 2024

    @remyers
    Contributor

    Fwiw, I also ran across this problem (Ubuntu 20.04)

    I guess you also installed a different boost version, because the 1.71 boost version in Ubuntu Focal 20.04 is not supported starting with #29066 and shouldn't even pass the cmake -B command.

    Yup, I have boost 1.74.0.3 installed.

    dpkg -s libboost-dev | grep 'Version'
    Version: 1.74.0.3ubuntu7
  10. fanquake commented on Sep 5, 2024

    @fanquake
    MemberAuthor

    The change to Boost Numeric in 1.81.0 may be enough to avoid the issue.

    I think this is the case, PR'd a change in #30821.

  11. added a commit that references this issue on Sep 5, 2024
    7f472e9
  12. locked and limited conversation to collaborators on Sep 5, 2025
  13. added a commit that references this issue on Oct 22, 2025
    ea036d3
  14. added a commit that references this issue on Nov 19, 2026
    e1c4f1c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions