[LLVMbugs] [Bug 11067] New: constexpr and initialization of static data members in templates

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Oct 5 03:38:39 PDT 2011


           Summary: constexpr and initialization of static data members in
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: davidhunter22 at gmail.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

This may relate this bug report http://llvm.org/bugs/show_bug.cgi?id=4503

The C++11 standard seems to have had a few modification late in the process
related to the initialization of static data members of template classes. Some
discussion of this topic

Anyway I was trying to build using a clang++ built from the trunk as of 140970
on a Linux box "2.6.31-23-server #75-Ubuntu SMP Fri Mar 18 19:23:09 UTC 2011
x86_64 GNU/Linux" in conjunction with trunk GCC 4.7.0 ( although the same issue
appears with 4.6.0 ). This led to errors from the GCC header files because of
constructs like this

template<typename T, T v> struct bar
    static constexpr T value = v;

template<typename T, T v> constexpr T bar<T,v>::value;

which compiles fine with GCC itself but clang gives 

constexpr.cpp:6:49: error: definition of initialized static data member 'value'
cannot be marked constexpr
template<typename T, T v> constexpr T bar<T,v>::value;

After reading about this for a while I still can't tell if this should be an
error or not. Anyway I believe someone out there is working on constexpr
related stuff and I wanted to make sure this issue was captured. It may be
clang is correct but that makes using clang with a recent GCC standard C++
library pretty impossible.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list