[LLVMbugs] [Bug 20029] New: Partially specialized constexpr variable template can't be used in a constant expression

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jun 13 08:54:59 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20029

            Bug ID: 20029
           Summary: Partially specialized constexpr variable template
                    can't be used in a constant expression
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Keywords: compile-fail
          Severity: normal
          Priority: P
         Component: C++1y
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ldionne.2 at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12655
  --> http://llvm.org/bugs/attachment.cgi?id=12655&action=edit
Test code to reproduce error with comments

Hi,

The following code does not compile with Clang r210819:
------------------------------------------------------------------------------
template <int i>
struct Foo;

template <typename T>
constexpr bool predicate = true;

template <typename T, bool = predicate<T>>
struct test { };

template struct test<Foo<0>>;
------------------------------------------------------------------------------

The error message is:
------------------------------------------------------------------------------
/Users/ldionne/code/hana/test/sandbox/worksheet.cpp:18:30: error: non-type
template argument is not a constant expression
template <typename T, bool = predicate<T>>
                             ^
/Users/ldionne/code/hana/test/sandbox/worksheet.cpp:21:28: note: while checking
a default template argument used here
template struct test<Foo<0>>;
                ~~~~~~~~~~~^
1 error generated.
------------------------------------------------------------------------------

The exact command line is:
~/code/llvm-git/build/bin/clang -std=c++1y -fsyntax-only
~/code/hana/test/sandbox/worksheet.cpp

I think this is related to 19571. I also attached a version of the above test 
code with a couple of comments showing things I've tried.


Regards,
Louis Dionne

-- 
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/20140613/15c8dd73/attachment.html>


More information about the llvm-bugs mailing list