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: "manu 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:12:56 +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
Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu.org
--- Comment #1 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> 2012-05-02 19:12:56 UTC ---
It fails to give an error with gcc 4.3 and gcc 4.8 also. Clang complains:
/home/manuel/pr53196.c:8:18: error: variable has incomplete type 'struct
foo_typo'
struct foo f = (struct foo_typo) { };
^~~~~~~~~~~~~~~~~~~~~
/home/manuel/pr53196.c:8:26: note: forward declaration of 'struct foo_typo'
struct foo f = (struct foo_typo) { };
^
1 error generated.
Interestingly, the code without the typo:
struct foo {
int i;
};
int
main(void)
{
struct foo f = (struct foo) { };
return 0;
}
is rejected by g++:
/home/manuel/pr53196.c:8:19: error: expected primary-expression before âstructâ
struct foo f = (struct foo) { };
^
/home/manuel/pr53196.c:8:19: error: expected â)â before âstructâ
struct foo f = (struct foo) { };
^