lballabio / QuantLib

The QuantLib C++ library
http://quantlib.org
Other
5.26k stars 1.78k forks source link

Build fails with QL_COMPILE_WARNING_AS_ERROR=ON due an uniniti #1968

Closed tomwhoiscontrary closed 2 months ago

tomwhoiscontrary commented 4 months ago

Building 1.34 like this:

$ grep PRETTY_NAME /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
$ gcc --version | head -1
gcc (GCC) 13.2.0
$ apt info libboost-all-dev 2>/dev/null | grep Version
Version: 1.74.0.3
$ git describe
v1.34
$ cmake .. -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Release -D QL_COMPILE_WARNING_AS_ERROR=ON
$ make -j 8

Fails with:

In file included from /usr/include/boost/function/detail/maybe_include.hpp:22,
                 from /usr/include/boost/function/function1.hpp:11,
                 from /usr/include/boost/test/tree/decorator.hpp:30,
                 from /usr/include/boost/test/tools/fpc_tolerance.hpp:19,
                 from /usr/include/boost/test/tools/fpc_op.hpp:19,
                 from /usr/include/boost/test/test_tools.hpp:54,
                 from /usr/include/boost/test/unit_test.hpp:18,
                 from /root/QuantLib/test-suite/preconditions.hpp:23,
                 from /root/QuantLib/test-suite/cashflows.cpp:20:
In member function 'void boost::function1<R, T1>::assign_to_own(const boost::function1<R, T1>&) [with R = boost::test_tools::assertion_result; T0 = long unsigned int]',
    inlined from 'boost::function1<R, T1>::function1(const boost::function1<R, T1>&) [with R = boost::test_tools::assertion_result; T0 = long unsigned int]' at /usr/include/boost/function/function_template.hpp:746:26,
    inlined from 'boost::function<R(T0)>::function(const self_type&) [with R = boost::test_tools::assertion_result; T0 = long unsigned int]' at /usr/include/boost/function/function_template.hpp:1105:76,
    inlined from 'boost::unit_test::decorator::precondition::precondition(predicate_t)' at /usr/include/boost/test/tree/decorator.hpp:280:61,
    inlined from 'void __static_initialization_and_destruction_0()' at /root/QuantLib/test-suite/cashflows.cpp:254:1:
/usr/include/boost/function/function_template.hpp:910:22: error: '*(unsigned char (*)[24])((char*)&<unnamed> + offsetof(boost::predicate_t, boost::function<boost::test_tools::assertion_result(long unsigned int)>::<unnamed>.boost::function1<boost::test_tools::assertion_result, long unsigned int>::<unnamed>.boost::function_base::functor))' is used uninitialized [-Werror=uninitialized]
  910 |           std::memcpy(this->functor.data, f.functor.data, sizeof(boost::detail::function::function_buffer));
      |           ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/boost/test/unit_test.hpp:19:
/root/QuantLib/test-suite/cashflows.cpp: In function 'void __static_initialization_and_destruction_0()':
/root/QuantLib/test-suite/cashflows.cpp:254:75: note: '<anonymous>' declared here
  254 | BOOST_AUTO_TEST_CASE(testNullFixingDays, *precondition(usingAtParCoupons())) {
      |                                                                           ^

While it builds fine without QL_COMPILE_WARNING_AS_ERROR set. Although it does report this as a warning, of course.

I believe this is to do with this test precondition:

BOOST_AUTO_TEST_CASE(testNullFixingDays, *precondition(usingAtParCoupons())) {

I have to confess i have no idea how to fix that, as i do not know Boost::Test preconditions or standard library functors!

sweemer commented 4 months ago

Do you also see the error with a more recent version of boost? Usually if you're using a very new compiler version you'll get fewer warnings and errors with the latest version of boost.

tomwhoiscontrary commented 4 months ago

@sweemer Currently i'm getting Boost from the OS package manager, so don't have a way to get anything newer. I am also hoping to get the build hooked up to vcpkg so i have more flexibility and control there, but that didn't work at my first attempt, and will need some fiddling.

I can easily try with older GCCs, though. But i'm using the official GCC docker images, and most of the older GCCs are on older Debians with older Boosts! GCC 12 is also on Debian 12 though.

sweemer commented 4 months ago

I made an example for building QuantLib with vcpkg here. Let me know if it doesn't work for you.

github-actions[bot] commented 2 months ago

This issue was automatically marked as stale because it has been open 60 days with no activity. Remove stale label or comment, or this will be closed in two weeks.