https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70543
Bug ID: 70543
Summary: [6 Regression] wrong non-const error for enable_if and
constexpr function
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: olegendo at gcc dot gnu.org
Target Milestone: ---
The code below compiles fine on GCC 5 (with -std=c++11 or -std=c++14), while on
GCC 6 (r234732) it says:
error: size of array 'foo' is not an integral constant-expression
char foo[value];
#include <type_traits>
#include <tuple>
template <typename Tuple> struct X
{
template <unsigned int I = 0> static constexpr
typename std::enable_if<I == std::tuple_size<Tuple>::value,
unsigned int>::type
calc (void)
{
return 0;
}
template <unsigned int I = 0> static constexpr
typename std::enable_if<I < std::tuple_size<Tuple>::value,
unsigned int>::type
calc (void)
{
return sizeof (typename std::tuple_element<I, Tuple>::type)
+ calc<I + 1> ();
}
static constexpr unsigned int value = calc ();
char foo[value];
};