[Bug c/17881] Incomplete type warning is issued even for prototypes

jsm at polyomino dot org dot uk gcc-bugzilla@gcc.gnu.org
Thu Oct 7 19:44:00 GMT 2004


------- Additional Comments From jsm at polyomino dot org dot uk  2004-10-07 19:44 -------
Subject: Re:  New: Incomplete type warning is issued even for
 prototypes

On Thu, 7 Oct 2004, jakub at gcc dot gnu dot org wrote:

> struct S;
> struct foo { void (*bar) (struct S); };
> void baz (struct S);
> 
> struct S { int i; };
> 
> void baz (struct S s)
> {
>   (void) s.i;
> }
> 
> warns about the incomplete type in prototype and function pointer, although
> the size of the object is not needed in those cases.

Although this is certainly a deliberate warning - and a warning, not a 
pedwarn - the comment justifying it

      /* If the arg types are incomplete in a declaration, they must
         include undefined tags.  These tags can never be defined in
         the scope of the declaration, so the types can never be
         completed, and no call can be compiled successfully.  */

is entirely wrong.  The case of tags defined at function prototype scope 
already gets its own warning.  Probably the only case for which this 
separate warning is appropriate is for parameters declared with void type 
(where a function with such parameter types can never be defined, only 
declared).



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17881



More information about the Gcc-bugs mailing list