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

            Bug ID: 86234
           Summary: non-type template argument is not a constant
                    expression
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhonghao at pku dot org.cn
  Target Milestone: ---

The code is as follow:

template <class T> struct B;

template <bool b>
struct C { };

template <class T>
struct A: C<B<A<T>>::value>
{
 typedef T Type;
};

template<class T>
struct B
{
 template<typename X> static int check(typename X::Type*);
 template<typename> static char check(...);
 static const bool value = (sizeof(check<T>(0)) == sizeof(int));
};

int main()
{
 return B<A<int>>::value;
}

clang++ rejects the code with error messages:
error: non-type template argument is not a constant expression
    struct A: C<B<A<T>>::value>

The code sample comes from a gcc bug report:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62255

A previous version of g++ also rejects the code, but it is fixed. g++ accepts
the code. 

I reported the difference as a bug to clang:
https://bugs.llvm.org/show_bug.cgi?id=37863

However, my reported bug was determined as an invalid bug. Shall g++ reject the
code as clang++ did?

Reply via email to