Path: utzoo!attcan!uunet!husc6!psuvax1!rutgers!columbia!garfield!aronoff From: aronoff@garfield (Avram Aronoff) Newsgroups: comp.lang.c Subject: Re: C Compiler bugs (was Re: Speaking of ksh) Message-ID: <5711@columbia.edu> Date: 17 Jun 88 10:01:13 GMT References: <15085@tut.cis.ohio-state.edu> <4421@haddock.ISC.COM> <8001@ncoast.UUCP> Sender: nobody@columbia.edu Reply-To: aronoff@garfield.UUCP (Avram Aronoff) Organization: Columbia University CS Department Lines: 15 > Many, many people have written... >| >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) ... >...but why does the code dump core? In the typical implementation of structure returns, a function returning a structure is passed a hidden pointer as its first argument, and uses that pointer to store the return value. Clearly, crt0.o assumes that main returns an int, and so passes no pointer. Main is trying to stuff a structure using argc as a pointer. This is a programmer error, not a compiler error. In a hosted environment, the system (albeit implicitly) assumes that main returns an int. Perhaps one of the ANSI include files should be made to contain a prototype for main. Hymie