[llvm-bugs] [Bug 32115] New: constexpr variable template requires default initialization even though it's not instantiated

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 1 21:17:31 PST 2017


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

            Bug ID: 32115
           Summary: constexpr variable template requires default
                    initialization even though it's not instantiated
           Product: clang
           Version: 3.9
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++14
          Assignee: unassignedclangbugs at nondot.org
          Reporter: arnetheduck at gmail.com
                CC: llvm-bugs at lists.llvm.org

clang rejects the following snippet:

template <typename T>
constexpr int kTag;

with the error:

default initialization of an object of const type 'const int'

even thought it's never instantiated - gcc (6.2) accepts the same code.

I'm not sure if gcc or clang is at fault, per the standard, but seems
reasonable that the error should be delayed until instantiation - that would be
consistent with a constexpr function for example that can remain undefined
unless it's actually used.

Eventually, I'm looking to specialize the tag for different type and letting
the compile catch any untagged types.

-- 
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/20170302/ee07e1b5/attachment.html>


More information about the llvm-bugs mailing list