Structure tags

Michael Kahl mkahl at world.std.com
Sun Feb 10 03:40:52 AEST 1991


In article <15135 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
>In article <595 at taumet.com> steve at taumet.com (Stephen Clamage) writes:
>-t-itoh at utsm.nm.fujitsu.co.jp (Tsutomu Itoh) writes:
>->1a.
>->struct foo {int i;};
>->struct foo;
>->struct foo bar;
>-Both of these are ok.  In 1a there is no incomplete declaration.
>
>Sure there is; the second "struct foo" type is not completed.
>If any essential use is made of "bar", there is an error.
>The second declaration (tag only) in effect cancels the previous
>"struct foo" type information for the following code.  This is a
>special wart spelled out in 3.5.2.3.

Are you certain?  3.5.2.3 says a tag-only struct declaration "specifies
a new type distinct from any type with the same tag IN AN ENCLOSING
SCOPE (if any)."  (My emphasis.)  From the Rationale it is clear that
the purpose of this feature is to allow a forward reference in an
*inner* block to a struct which already exists in an *outer* block
but which will be redeclared in the inner block.  I don't see anything
in the Standard to suggest that a tag-only declaration "cancels" a
previous declaration in the *same* scope.

-- 
Michael Kahl, Symantec Corporation
mkahl at world.std.com  -or-  75236.3146 at compuserve.com
Disclaimer:  Keep this quiet; what my employer doesn't know won't get me fired.



More information about the Comp.std.c mailing list