C Compiler bugs (was Re: Speaking of ksh)

Brandon S. Allbery allbery at ncoast.UUCP
Wed Jun 15 13:05:57 AEST 1988


As quoted from <4421 at haddock.ISC.COM> by karl at haddock.ISC.COM (Karl Heuer):
+---------------
| In article <15085 at tut.cis.ohio-state.edu> lvc at tut.cis.ohio-state.edu (Lawrence V. Cipriani) writes:
| >Then there was the bug where if you had a structure declaration right before
| >main and forget to end it with a ; the program would core dump on exit:
| >	struct blob { int a, b, c; } /* missing ; */
| >	main(argc, argv) ...
| 
| Why should it be considered a "compiler bug" when a syntactically correct
| program containing a user bug dumps core?  It seems to me that the appropriate
| "fix" is to make sure that lint complains about the mismatched declaration.
| 
| Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint
+---------------

(blink)  Whoops!  Mr. Heuer just earned his title.  That *is* a valid
declaration:  it says that the function main() returns a (struct blob), and
declares the (struct blob) at the same time.  Good point.

...but why does the code dump core?  Admitted, the cleanup code in crt0 will
dosciver a type mismatch, but how many programs exit by return'ing from main?
If it happened during an exit(), it's a legitimate bug somewhere.  (If it
happened in crt0, then it's an artifact of the compiler's method of
returning structs.)
-- 
Brandon S. Allbery			  | "Given its constituency, the only
uunet!marque,sun!mandrill}!ncoast!allbery | thing I expect to be "open" about
Delphi: ALLBERY	       MCI Mail: BALLBERY | [the Open Software Foundation] is
comp.sources.misc: ncoast!sources-misc    | its mouth."  --John Gilmore



More information about the Comp.lang.c mailing list