This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
Consider: typedef struct { int a; } b_t; int foo() { b_t d; struct b_t * c = &d; c->a; } gcc 3.2 says : a.c: In function `foo': a.c:2: warning: initialization from incompatible pointer type a.c:2: dereferencing pointer to incomplete type GNU C version 3.4 20030914 (experimental) (i686-pc-linux-gnu) says : a.c: In function `foo': a.c:2: error: dereferencing pointer to incomplete type Note the missing warning on initialisation. This can be moderately confusing because the latter looks exactly like a "missing header" problem, but in fact the problem is prepending the "struct" before the typedef name, which is actually an incomplete type of "struct b_t". The missing warning makes it obvious that it's not as simple as a missing header.
Right, a mailine regression. What a vicious piece of code. The g++ front end gives this, btw, which I think is a good reason to change your programming language :-) g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.c -W -Wall x.c: In function `int foo()': x.c:2: error: using typedef-name `b_t' after `struct' x.c:2: warning: statement has no effect
The regresion happened between 20030830 and 20030902. I want to say it was caused by: <http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00003.html> Or one of these two: 2003-08-30 Zack Weinberg <zack@codesourcery.com> * c-tree.h: Delete COMPARE_DIFFERENT_TU from enumeration. * c-typeck.c (same_translation_unit_p): New function. (comptypes): Use it instead of flags parameter to identify structure types from different translation units. * c-decl.c (duplicate_decls): Always call comptypes with COMPTYPE_STRICT flags argument. (c_reset_state): Set BLOCK_SUPERCONTEXT of the block formed to file_scope_decl. 2003-08-30 Zack Weinberg <zack@codesourcery.com> * c-tree.h (C_TYPE_INCOMPLETE_VARS): New macro. * c-decl.c (struct c_scope): Remove "incomplete" field. (pushdecl): Attach variables with incomplete types to the TYPE_MAIN_VARIANT of the incomplete type in question. (finish_struct): Look at C_TYPE_INCOMPLETE_VARS for variables to complete, not at current_scope->incomplete. All such variables do need completion. These are the only patches which touched the c front-end which could cause this problem.
This is a very minor issue: postponed until GCC 3.4.1.
Fixed by the c-decl.c rewrite: http://gcc.gnu.org/ml/gcc-patches/2004-03/msg01280.html
fixed in 3.5
Suspending bugs which could be fixed by backporting the c-decl.c rewrite to 3.4.
Fixed in 3.5, won't be fixed in 3.4.x.