is f().c legal? How about (&(f()))->c ?

Guy Harris guy at auspex.UUCP
Sun Jan 29 09:45:07 AEST 1989


>I am trying to figure out why C compilers like the latter expression
>and cant handle the first expression.

Because they're buggy.

In particular, pre-S5 versions of PCC (upon which the Sun compiler is
based) had some bogus code for determining whether something was a legal
structure reference.  The S5 version had a differently bogus version
that attempted to fix the first version.  The SunOS 4.0 compiler has one
that avoids both of those forms of bogosity; however, it still doesn't
catch some other illegal constructs.  I think the 4.3-tahoe compiler has
something to catch those as well.

HP-UX may, at least on the 68K-based HPs, also have a PCC-derived
compiler, and thus have inherited one or more of the aforementioned
bugs.

This is why "my compiler does/doesn't accept this construct" is not
always a good test of whether the construct is legal or not.  That's why
you need a standard - and conformance tests, so that bugs such as the
aforementioned get caught and, hopefully, fixed.



More information about the Comp.std.c mailing list