SciCompMod / memilio

Modular spatio-temporal models for epidemic and pandemic simulations
https://scicompmod.github.io/memilio/
Apache License 2.0
52 stars 15 forks source link

Error when compiling on Mac with new boost #1021

Open DavidKerkmann opened 2 months ago

DavidKerkmann commented 2 months ago

Bug description

When compiling on my machine, I get the error below. Most likely happened after the changes from #983.

Version

Mac

To reproduce

Build memilio as usual.

Relevant log output

/Users/david/Documents/HZI/memilio/cpp/memilio/../memilio/mobility/graph.h:344:5: error: use of the 'likely' attribute is a C++20 extension [-Werror,-Wc++20-extensions]

BOOST_OUTCOME_TRY(auto&& mobility_data_twitter,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/david/Documents/HZI/memilio/cpp/build/_deps/boost-src/boost/outcome/try.hpp:345:32: note: expanded from macro 'BOOST_OUTCOME_TRY'
#define BOOST_OUTCOME_TRY(...) BOOST_OUTCOME_TRY_CALL_OVERLOAD(BOOST_OUTCOME_TRY_INVOKE_TRY, __VA_ARGS__)
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/david/Documents/HZI/memilio/cpp/build/_deps/boost-src/boost/outcome/try.hpp:161:35: note: expanded from macro 'BOOST_OUTCOME_TRY_CALL_OVERLOAD'
  BOOST_OUTCOME_TRY_OVERLOAD_GLUE(BOOST_OUTCOME_TRY_OVERLOAD_MACRO(name, BOOST_OUTCOME_TRY_COUNT_ARGS_MAX8(__VA_ARGS__)), (__VA_ARGS__))
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/david/Documents/HZI/memilio/cpp/build/_deps/boost-src/boost/outcome/try.hpp:158:55: note: expanded from macro 'BOOST_OUTCOME_TRY_OVERLOAD_MACRO'
#define BOOST_OUTCOME_TRY_OVERLOAD_MACRO(name, count) BOOST_OUTCOME_TRY_OVERLOAD_MACRO1(name, count)
                                                      ^
note: (skipping 6 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
/Users/david/Documents/HZI/memilio/cpp/build/_deps/boost-src/boost/outcome/try.hpp:221:3: note: expanded from macro 'BOOST_OUTCOME_TRY2_SUCCESS_LIKELY'
  BOOST_OUTCOME_TRYV2_SUCCESS_LIKELY(unique, retstmt, var, __VA_ARGS__);                                                                                             \
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/david/Documents/HZI/memilio/cpp/build/_deps/boost-src/boost/outcome/try.hpp:203:3: note: expanded from macro 'BOOST_OUTCOME_TRYV2_SUCCESS_LIKELY'
  BOOST_OUTCOME_TRY_LIKELY_IF(::BOOST_OUTCOME_V2_NAMESPACE::try_operation_has_value(unique));                                                                              \
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/david/Documents/HZI/memilio/cpp/build/_deps/boost-src/boost/outcome/try.hpp:175:60: note: expanded from macro 'BOOST_OUTCOME_TRY_LIKELY_IF'
#define BOOST_OUTCOME_TRY_LIKELY_IF(...) if(__VA_ARGS__) [[likely]]

Add any relevant information, e.g. used compiler, screenshots.

Compiler: Clang 13.0.0 x86_64-apple_darwin20.6.0
Machine: MacBook Pro
Operating System: macOS BigSur

Checklist

reneSchm commented 2 months ago

We did encounter this, and added the line

        target_compile_options(boost INTERFACE "-Wno-c++20-attribute-extensions")

in cpp/thirdparty/CMakeLists.txt. Could you please try to change this to -Wno-c++20-extensions and tell me if that fixed it?

reneSchm commented 2 months ago

Okay, so it seems like apple clang does not follow the diagnostics reference here. The exact warning you got should be toggled by -Wc++20-attribute-extensions, instead it is only managed by -Wc++20-extensions, which is supposed to toggle several other warnings in addition to the attribute warning. We probably should only add a special case for apple using this stronger toggle. Disabling too many warnings seems unnecessary (and potentially bad?).