Broken compilers (Was Portability of passing/operating on structures)
James D. Allen
jamesa%betelgeuse at Sun.COM
Fri Oct 21 14:13:48 AEST 1988
In article <35317 at XAIT.Xerox.COM>, g-rh at XAIT.Xerox.COM (Richard Harter) writes:
> >As for my opinion: If your compiler's broken, take it up with your vendor.
>
> ...The things that make programs non
> portable are almost always frills and slop. Things like passing structures
> are frills.
Among the compiler bugs I have contended with are:
1)
struct {
whatever;
} st;
. . .
/* the next will be treated as though it were "foo(&st);" */
foo(st);
(To print
"warning: compiler writer too lazy to implement structure arguments"
seems far more reasonable than to silently substitute a totally different
construct just because it *might* have been the programmer's intent.)
2)
main() {
short s = -3;
foo(s);
}
foo(s) short s; {
short *sp = &s;
/* The next will print -1 rather than -3. */
printf("%d", *sp);
}
(I think this arose because a little-Endian compiler was ported to a
big-Endian machine without ample thought and/or testing.)
These were (supposedly) important commercial compilers, not "toys."
By coincidence they were from the same large vendor. I won't mention
names but the software house is operated by a magazine columnist
who frequently points out the "design errors" Dennis Ritchie made when
he invented C. :-}
Moral: Test your compiler. If it works assume you can use most reasonable
constructs. If not, warn your fellow netlanders and throw the compiler away.
James D. Allen -- Still dreaming on my way to H***.
More information about the Comp.lang.c
mailing list