Boost logo

Boost :

Subject: [boost] Clang 600 and BOOST_SYSTEM_CONSTEXPR causes error_code.hpp compile failure.
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2018-07-05 15:12:41


Having failed to build Boost libraries using Clang 6.0.0 using b2/bjam on Windows, I am now trying instead to use Codeblocks on
Windows 10 to build static libraries.

It comes to grief with these messages (the berbose gory details can be posted if anyone can help).

In file included from I:\modular-boost\boost/system/system_error.hpp:14:
I:\modular-boost\boost/system/error_code.hpp:409:88: error: variable does not have a constant initializer
template<class T> BOOST_SYSTEM_REQUIRE_CONST_INIT system_error_category cat_holder<T>::system_category_instance;
                                                                                       ^~~~~~~~~~~~~~~~~~~~~~~~
I:\modular-boost\boost/system/error_code.hpp:409:19: note: required by 'require_constant_initialization' attribute here
template<class T> BOOST_SYSTEM_REQUIRE_CONST_INIT system_error_category cat_holder<T>::system_category_instance;
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I:\modular-boost\boost/system/error_code.hpp:392:44: note: expanded from macro 'BOOST_SYSTEM_REQUIRE_CONST_INIT'
# define BOOST_SYSTEM_REQUIRE_CONST_INIT [[clang::require_constant_initialization]]
                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This seems to be the ultimate cause

I:\modular-boost\boost/system/error_code.hpp:226:41: note: non-constexpr constructor 'error_category' cannot be used in a constant
expression
        BOOST_SYSTEM_CONSTEXPR explicit std_category( boost::system::error_category const * pc ): pc_( pc )
                                        
Is this because BOOST_SYSTEM_CONSTEXPR should not be defined?

I note this in error_code.hpp

#if defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8) && __cplusplus >= 201700L
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83835
# undef BOOST_SYSTEM_HAS_CONSTEXPR
#endif

should this undef list also include clang, and if so which versions 600?

Or is there something about Boost.config and Codeblocks on Windows?

Adding unconditional # undef BOOST_SYSTEM_HAS_CONSTEXPR seems to work.

Suggestions welcome.

Paul

---
Paul A. Bristow
Prizet Farmhouse
Kendal UK LA8 8AB
+44 (0) 1539 561830

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk