[LLVMbugs] [Bug 18283] New: Const int initialized with curly braces is not a compile time constant

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Dec 19 09:27:33 PST 2013


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

            Bug ID: 18283
           Summary: Const int initialized with curly braces is not a
                    compile time constant
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: detunized at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

While compiling the following code in C++98 or C++03 (not in C++11) mode Clang
produces an error:

template <int> struct A {};

int const i = { 42 };
typedef A<i> Ai;


The error:

test.cpp:4:11: error: non-type template argument of type 'int' is not an
integral constant expression
typedef A<i> Ai;
          ^
test.cpp:4:11: note: initializer of 'i' is not a constant expression
test.cpp:3:11: note: declared here
int const i = { 42 };
          ^

As far as I understand "i = 42" and "i = { 42 }" should be equivalent and
should produce no error.


The following code compiles without problems:

int const j = 42;
typedef A<j> Aj;

-- 
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/20131219/d44c88dd/attachment.html>


More information about the llvm-bugs mailing list