[LLVMbugs] [Bug 13517] Static constexpr definitions used inside template
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Jan 8 14:55:33 PST 2013
http://llvm.org/bugs/show_bug.cgi?id=13517
Richard Smith <richard-llvm at metafoo.co.uk> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
--- Comment #5 from Richard Smith <richard-llvm at metafoo.co.uk> 2013-01-08 16:55:33 CST ---
(In reply to comment #0)
> [...] when I make the class A, a template like this:
[...]
> Clang crashes
I cannot reproduce this with Clang trunk; I assume it has been fixed.
> if I change the definition line for F to this:
[...]
> Then clang produces this error:
>
> error: redefinition of 'F' with a different type
> constexpr typename std::remove_const<decltype(A<X>::F)>::type A<X>::F;
> ^
> note: previous definition is here
> static constexpr auto F = L();
> ^
This error is correct. 'constexpr' and 'auto' are red herrings here. Reduced
testcase:
template<class X> struct A { static int F; };
template<class X> decltype(A<X>::F) A<X>::F;
Per C++11 [temp.type]p2, "If an expression e involves a template parameter,
decltype(e) denotes a unique dependent type." Therefore the type of A<X>::F
does not match the type in the template.
> Also, does C++ require the definition outside of the class? It would be nicer
> when using constexpr and auto, just to have the the static member defined at
> the point of declaration.(like it is for integers), but perhaps that is not
> conformant with C++11.
static const integral members work just like static constexpr members in this
regard. In either case, you must provide a definition outside the class if the
data member is odr-used (more-or-less, if its address is used, not just its
value).
--
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