Is this a GCC bug ?

Karl Heuer karl at haddock.ima.isc.com
Fri Feb 2 03:12:37 AEST 1990


In article <355 at charyb.COM> dan at charyb.UUCP (Dan Mick) writes:
>In article <7948 at shlump.nac.dec.com> nadkarni at ashok.dec.com writes:
>|Is this a bug in the Gnu CC compiler or is it illegal C ?
>|	typedef void foo(struct urb *p);
>|	struct urb { int i; } ;
>|bug.c:1: warning: `struct urb' declared inside parameter list
>|bug.c:1: warning: such a name is accessible only within its parameter list,
>|bug.c:1: warning: which is probably not what you want.

The problem is that you have two declarations of `struct urb', and they have
nonintersecting scopes--so they actually declare two different types.  You
should either put the typedef before the prototype, or else force a common
scope by adding the empty declaration `struct urb;' at the top.

>[partially correct analysis omitted]
>The program still works, right?

Since it can be derived that `all struct pointers smell the same', the program
will probably work.  But when you try to invoke foo() with an argument of type
`struct_urb_2_pointer', the prototype requires the compiler to convert it to a
`struct_urb_1_pointer', which may yield another warning.

Karl W. Z. Heuer (karl at ima.ima.isc.com or harvard!ima!karl), The Walking Lint



More information about the Comp.lang.c mailing list