Another bug in C compilers
Rob Brunner X2830
brunner at sdsioa.UUCP
Sat Aug 2 03:39:47 AEST 1986
> I believe I've found a bug in the C compiler for the Sys 5 Rel 2 3B20.
> Say we have a structure declared as:
> struct ABC
> {
> stuff
> };
> and then follow it with:
> struct ABC;
> ... no error ....
Which is equivalent to using:
int ;
as far as basic parsing is concerned.
This is NOT A BUG, but a feature... If you look in K&R on pages 215,216
(in section 18.2-Declarations) you'll see essentially the following:
declaration:
decl-specs init-decl-list[opt] ; /* init-decl-list left out above */
... /* this is the key... you normally */
/* use something like 'int k;' this */
/* allows 'int ;' */
decl-specs:
type-spec decl-specs[opt] ; /* decl-specs left out above */
...
type-spec:
...
struct-or-union-spec
...
struct-or-union-spec:
...
struct identifier
...
Why this would ever be done is beyond me. Anyone have any applications
of this (and want to admit it)? It might not be useful, but it is
certainly legal.
--
Rob Brunner email:
Scripps Institution of Oceanography brunner at sdsioa.UUCP
Mail Code A-010, UC San Diego sdsioa!brunner at sdcsvax
San Diego, CA 92093 {backbone}!sdcsvax!sdsioa!brunner
Phone: (619) 534-2040 (work) (619) 452-7656 (home)
More information about the Comp.lang.c
mailing list