[Bug c++/60698] New: non-empty braced-or-equal-initializer of non-static data member T[N] in class template results in error diagnostic, if T is a class
filip.roseen at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Mar 28 17:06:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60698
Bug ID: 60698
Summary: non-empty braced-or-equal-initializer of non-static
data member T[N] in class template results in error
diagnostic, if T is a class
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: filip.roseen at gmail dot com
Created attachment 32476
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32476&action=edit
testcase.cpp
struct A { };
template<class>
struct B {
A a[1] = { A () };
};
int main () { B<void> b; }
--------------------------------------------------
The above is a legal construct, but gcc rejects it with the following
diagnostic:
> testcase.cpp: In constructor ‘constexpr B<void>::B()’:
> testcase.cpp:4:8: error: invalid initializer for array member ‘A B<void>::a
[1]’
> struct B {
> ^
> testcase.cpp: In function ‘int main()’:
> testcase.cpp:8:24: note: synthesized method ‘constexpr B<void>::B()’ first
required here
> int main () { B<void> {}; }
[ Note: Both `clang` and `icc` correctly accepts the snippet provided. ]
More information about the Gcc-bugs
mailing list