Closed vinniefalco closed 2 years ago
I pushed a fix for defective gcc 4.7.x
error_code
as a member of a struct, contained in objects which are constexpr variables with static storage duration:(I switched it to the enum as a temporary workaround)
The three "default" values (what you get with a default-constructed object) are constexpr here (header
contains a metadata
data member)
https://github.com/vinniefalco/http_proto/blob/cbdbb6e959258eebb8970a9b4f1950709d1998b8/include/boost/http_proto/detail/impl/header.ipp#L73
OK, but what is the simplest self-contained code example that both demonstrates the failure and is representative of your actual code?
OK, but what is the simplest self-contained code example that both demonstrates the failure and is representative of your actual code?
Given this code:
#include <boost/system/error_code.hpp>
struct M
{
constexpr M() = default;
boost::system::error_code ec;
};
struct H
{
constexpr H() = default;
M m;
};
H const& f()
{
static constexpr H h;
return h;
}
The current tip of develop fails to compile it at all under C++11.
Changing error_code::error_code()
in System from BOOST_SYSTEM_CONSTEXPR
to BOOST_CONSTEXPR
will compile under C++11 except for GCC 4.7.x (compiler bug I suppose, I struggled to find a workaround but failed)
Applying this pull request will it compile under C++11, except that it will not be constexpr for GCC 4.7.x. My library does not support anything below 4.8 anyway, so this should be no worse than before my change.
This makes
error_code
default constructorconstexpr
in C++11 instead of just C++14