This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/53196] unknown struct name in C99 compound initializer doesn't generate error
- 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 21:17:01 +0000
- Subject: [Bug c/53196] unknown struct name in C99 compound initializer doesn't generate error
- Auto-submitted: auto-generated
- References: <bug-53196-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53196
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-02 21:17:01 UTC ---
(In reply to comment #3)
> (In reply to comment #2)
> > That's simply because compound literals aren't valid in C++.
>
> So this page is wrong?
> http://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html
I didn't realise it was claimed to work in C++, but yes, I guess the docs are
wrong. C++ provides several portable forms of initialization, there's really
no need to support another non-standard one.
These will all work for aggregate types (including "C structs")
foo f{};
foo f = {};
foo f = foo{};
foo f = foo();
I'll propose a patch to fix the docs.