[Bug c++/91953] [8/9/10 Regression] G++ rejects lambda with constexpr variable
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Oct 1 17:18:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91953
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Reduced testcase:
template<typename _Tp, _Tp __v>
struct integral_constant
{
static constexpr _Tp value = __v;
typedef _Tp value_type;
typedef integral_constant<_Tp, __v> type;
constexpr operator value_type() const noexcept { return value; }
constexpr value_type operator()() const noexcept { return value; }
};
auto f = [](auto value)
{
constexpr auto i = value;
return i;
};
void
foo ()
{
f (integral_constant<int, 0>{});
}
So, shall value be constexpr because integral_constant is an empty class?
This boils down to
struct S {};
void
foo (S s)
{
constexpr S x = s;
}
which GCC 7 as well as clang accepted, but GCC 8+ rejects.
More information about the Gcc-bugs
mailing list