On Thu, 14 Jan 2016, Prathamesh Kulkarni wrote:

> Hi,
> For test-case containing only the following declaration:
> static struct undefined_struct object;
> gcc rejects it at -O0 in assemble_variable() with error "storage size
> of <var> is unknown",
> however no error is reported when compiled with -O2.

Cf bug 24293 (for the -fsyntax-only case) - does this patch fix that?

> g++ rejects it during parsing. I tried similarly in C FE by adding a
> check for decl with incomplete struct/union type in finish_decl(),
> however that fails to compile the following case:
> typedef struct foo foo_t;
> foo_t x;
> struct foo { int i; };
> g++ rejects the above case as well but gcc accepts it.
> Do C and C++ standards differ in this regard ?

I don't know about C++, but this sort of thing is valid C if the type is 
complete at the end of the translation unit or is an incomplete array type 
(but not in the case where the variable is static - such a case with 
static, if supported, is an extension).

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to