From cd062d6684908d526be7423f8f1057b891254a3c Mon Sep 17 00:00:00 2001 From: fanquake Date: Thu, 5 Sep 2024 13:46:51 +0100 Subject: [PATCH] build: work around issue with Boost <= 1.80 and Clang >= 18 Our current minimum supported Boost is `1.73.0`. However, when compiling with Boost `1.74.0` (Debian Stable), using Clang `18`, compilation fails with: ```bash 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(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(expr) | ^ 2 errors generated. ``` Work around this issue by ignoring this diagnostic for this include. I did attempt to just downgrade the error into a warning, but that did not seem to work. See https://github.com/bitcoin/bitcoin/issues/30751 for further discussion. --- src/txmempool.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/txmempool.h b/src/txmempool.h index d0cb41a078..7fdf1c5a39 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -23,7 +23,17 @@ #include #include +// This works around a bug in Boost <= 1.80.0 when using Clang >=18. +// See https://github.com/bitcoin/bitcoin/issues/30751. +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wenum-constexpr-conversion" +#endif #include +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + #include #include #include