Another bug in C compilers
Rick Genter
rgenter at BBN-LABS-B.ARPA
Thu Jul 31 22:41:33 AEST 1986
Accepting the declaration:
struct ABC;
is not a bug, it's a feature. This is termed a *vacuous declaration*, and
permits the definition of cyclic recursive structures in an inner scope where
one of the structures renames a structure from on outer scope. For example,
struct ABC {
int foo;
double mumble;
};
main ()
{
struct ABC;
struct DEF {
char bar[ 128 ];
int bletch;
struct ABC *foop;
} a;
struct ABC {
double giant[ 5000 ];
struct DEF *barp;
} b;
<the rest of main>
}
If you didn't have the vacuous declaration, the compiler would think that
"foop" pointed at a structure consisting of "int foo" and "double mumble".
Referencing foop->giant would get you "illegal structure pointer combination".
--------
Rick Genter BBN Laboratories Inc.
(617) 497-3848 10 Moulton St. 6/512
rgenter at labs-b.bbn.COM (Internet new) Cambridge, MA 02238
rgenter at bbn-labs-b.ARPA (Internet old) linus!rgenter%BBN-LABS-B.ARPA (UUCP)
CHUBBY CHECKER just had a CHICKEN SANDWICH in downtown DULUTH!
More information about the Comp.lang.c
mailing list