[Bug c++/86234] New: non-type template argument is not a constant expression
zhonghao at pku dot org.cn
gcc-bugzilla@gcc.gnu.org
Wed Jun 20 10:56:00 GMT 2018
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?
More information about the Gcc-bugs
mailing list