C Compiler bugs

Doug Gwyn gwyn at brl-smoke.ARPA
Thu Jun 9 10:31:02 AEST 1988


In article <15298 at tut.cis.ohio-state.edu> lvc at tut.cis.ohio-state.edu (Lawrence V. Cipriani) writes:
>As far as the compiler is concerned main is just another subroutine.

Ok, then it cannot complain if main is (inadvertently) declared as
returning a structure.

>I think the crt0.o file ... was recoded to always expect an int from
>main even if it returned something else ...

Yes, AT&T crt0.o has been this way for many years and it is necessary
for the ANSI C hosted environment.

>I guess I don't see what point I am missing.

I thought you had said that the compiler had been "fixed" so that
it did not allow the (inadvertent) declaration of main as returning
a structure that led to the run-time core dump previously reported.
>From what you've been saying, it appears that that user error could
still lead to exactly the same symptom.  I don't think this needs
"fixing", by the way, but the right way to do it would be to have
the compiler know whether the compilation was for a freestanding or
hosted environment (e.g. "scc" vs. "cc" in the AT&T UNIX world) and
in the latter case have it "know" the only two valid interfaces for
the definition of the main() function.  (Too bad X3J11 decided to
allow two incompatible ones; if there were only one the compiler
could simply predeclare main().)



More information about the Comp.lang.c mailing list