Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!think!ames!amdahl!oliveb!sun!betelgeuse!jamesa From: jamesa%betelgeuse@Sun.COM (James D. Allen) Newsgroups: comp.lang.c Subject: Broken compilers (Was Portability of passing/operating on structures) Message-ID: <73946@sun.uucp> Date: 21 Oct 88 04:13:48 GMT References: <8810111934.AA21941@ucbarpa.Berkeley.EDU> <8308@alice.UUCP> <35317@XAIT.Xerox.COM> Sender: news@sun.uucp Lines: 48 In article <35317@XAIT.Xerox.COM>, g-rh@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***.