This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/53196] unknown struct name in C99 compound initializer doesn't generate error


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) { };
                   ^


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]