This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/70543] [6 Regression] wrong non-const error for enable_if and constexpr function


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70543

--- Comment #1 from Oleg Endo <olegendo at gcc dot gnu.org> ---
A slightly reduced version:

#include <type_traits>

template <typename Tuple> struct X
{
  template <unsigned int I = 0> static constexpr
  typename std::enable_if< I == 5, unsigned int>::type
  calc (void)
  {
    return 0;
  }

  template <unsigned int I = 0> static constexpr
  typename std::enable_if< I != 5, unsigned int>::type
  calc (void)
  {
    return 1 + calc<I + 1> ();
  }

  static constexpr unsigned int value = calc ();     // <<<<<<<

  char foo[value];
};


If the marked line is changed to

  static constexpr unsigned int value = calc<0> ();

it compiles fine.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]