[llvm-bugs] [Bug 37863] New: non-type template argument is not a constant expression

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 19 22:23:27 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37863

            Bug ID: 37863
           Summary: non-type template argument is not a constant
                    expression
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zhonghao at pku.org.cn
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

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. 
Would you please check whether it indicates a bug in clang++?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180620/dfc27d17/attachment.html>


More information about the llvm-bugs mailing list