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 19:32:03 +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 #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-02 19:32:03 UTC ---
(In reply to comment #1)
> Interestingly, the code without the typo:
>
> struct foo {
> int i;
> };
>
> int
> main(void)
> {
> struct foo f = (struct foo) { };
> return 0;
> }
>
> is rejected by g++:
That's simply because compound literals aren't valid in C++.
Also, to be valid C the initializer should be { 0 }, allowing an empty
initializer is a GNU C extension.