[LLVMbugs] [Bug 14948] New: braced-init-list initialization of template static data member rejected
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Jan 14 06:32:02 PST 2013
http://llvm.org/bugs/show_bug.cgi?id=14948
Bug #: 14948
Summary: braced-init-list initialization of template static
data member rejected
Product: clang
Version: 3.2
Platform: PC
OS/Version: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: C++11
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: ed at catmur.co.uk
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
clang 3.2 rejects the following program:
struct X {};
template<typename T> struct Q { static X x; };
template<> X Q<int>::x{};
source.cpp:3:31: error: expected ';' after top level declarator
template<typename T> X Q<T>::x{};
This is required by the standard (14.7.3p13) to allow direct
default-initialization.
Also broken are the cases where X is an array, where X is a nonclass type,
where the braced-init-list is nonempty, and where the definition is a template
declaration instead of a template static data member explicit initialization:
template<> X Q<int>::x[]{};
template<> int Q<int>::x{};
template<> int Q<int>::x{1};
template<typename T> X Q<T>::x{};
Non-template static data member definitions are fine.
As a workaround, one can insert an equals sign before the braced-init-list,
although where X is a nonaggregate class type this has semantic result of
changing direct-initialization to copy-initialization.
gcc (4.7.2) accepts this.
--
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