This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/53205] New: Compound literals don't allow empty initializer lists
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 02 May 2012 22:48:03 +0000
- Subject: [Bug c++/53205] New: Compound literals don't allow empty initializer lists
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53205
Bug #: 53205
Summary: Compound literals don't allow empty initializer lists
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: redi@gcc.gnu.org
I don't care about this extension myself, but we should probably make it work
properly in C++ (see PR 40076 for another bug) or deprecate it (C++ offers
several alternative forms of initialization)
http://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html
struct foo { int i; };
int main()
{
struct foo f = ((struct foo) { });
}
cl.cc: In function âint main()â:
cl.cc:5:22: error: expected primary-expression before âstructâ
struct foo f = ((struct foo) { });
^
cl.cc:5:22: error: expected â)â before âstructâ
struct foo f = ((struct foo) { });
^
An empty initializer list is allowed in C++, and as an extension in GNU C, so
it should probably work here.