Opened 5 months ago

Closed 6 weeks ago

#13625 closed Bugs (fixed)

Boost.test fail to compile with -Werror=missing-declarations on some architectures

Reported by: Martin Quinson <martin.quinson@…> Owned by: Raffi Enficiaud
Milestone: Boost 1.69 Component: test
Version: Boost 1.67.0 Severity: Problem
Keywords: Cc: mquinson@…



here is the error code we get:

18:07:49 In file included from /opt/boost/include/boost/test/unit_test.hpp:19:0,
18:07:49                  from /builds/workspace/SimGrid-Multi/build_mode/ModelChecker/node/simgrid-centos7-x64/build/SimGrid-3.20.90/src/mc/sosp/PageStore_test.cpp:8:
18:07:49 /opt/boost/include/boost/test/unit_test_suite.hpp: In function 'bool init_unit_test()':
18:07:49 /opt/boost/include/boost/test/unit_test_suite.hpp:375:6: error: no previous declaration for 'bool init_unit_test()' [-Werror=missing-declarations]
18:07:49  bool init_unit_test()                   {
18:07:49       ^~~~~~~~~~~~~~
18:07:49 cc1plus: all warnings being treated as errors

  • System::

Centos7 with Boost 1.67 compiled from sources in /opt.

  • Full logs::,node=simgrid-centos7-x64/5662/consoleFull

  • Workaround::

simply add bool init_unit_test(); before including boost/test/unit_test.hpp

The weird thing is that the exact same code is compiling like a charm on many other platforms that we test. We saw another instance of this bug back in May 2017, on NetBSD systems where we compiled Boost.test from the sources. At that time, we simply added the workaround described above without too much thinking.

Thanks for this great libraries, Mt

Change History (5)

comment:1 Changed 7 weeks ago by Raffi Enficiaud


I am trying to reproduce this. The header

#include <boost/test/unit_test_suite.hpp>

that contains the definition of bool init_unit_test(); is included at the top of boost/test/unit_test.hpp.

I do not quite understand why you are experiencing this error. I do not have access to the logs you mentioned.

comment:2 Changed 7 weeks ago by Raffi Enficiaud

Owner: changed from Gennadiy Rozental to Raffi Enficiaud

comment:3 Changed 7 weeks ago by Raffi Enficiaud

I checked the option -Werror=missing-declarations on GCC and clang (apple). With GCC, nothing compiles and with clang everything works well.

I believe that enabling this option is a bit annoying as it renders legit C++ to be erroneous. What I can do instead is to add the declaration of init_unit_test (and other variants) such that your code compiles.

Would that be ok?

comment:4 Changed 7 weeks ago by Raffi Enficiaud

I removed the warning from boost.test instead. See rev 972cdd4f367db2f4b3b67521b4259cfa8bf4ba1d.

comment:5 Changed 6 weeks ago by Raffi Enficiaud

Milestone: To Be DeterminedBoost 1.69
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.