Boost logo

Boost :

Subject: Re: [boost] Clang 600 and BOOST_SYSTEM_CONSTEXPR causes error_code.hpp compile failure.
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2018-07-06 01:34:27


On 6/07/2018 03:12, Paul A. Bristow wrote:
> 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 think the issue is that BOOST_SYSTEM_CONSTEXPR is expected to expand
to "constexpr" (according to the error you're getting) but is instead
expanding to "".

Normally the latter occurs in environments that don't support constexpr
while the former occurs in environments that do; conversely I'd assume
that BOOST_SYSTEM_REQUIRE_CONST_INIT would also be disabled in
environments that don't support constexpr.

So some of the defines appear to think that constexpr is supported while
others think that it is not. Perhaps you can focus on what conditions
drive each of these definitions?

I don't know what the actual resolution to this is, but perhaps it helps?


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