Wierd core dump on sparc-1

Adam S. Denton asd at cbnewsj.att.com
Sat Jan 26 03:20:34 AEST 1991


>>I've got a rather simple little C program that dumps core at 
>>the first "{" of main() (according to gdb and saber).
>>Any hints as to what could be causing this?

This can happen when you leave out a semicolon before main():

    /* type definition section */
    ...
    struct foo {
       int glorp;
       NERD *bar;
    }                    /* NOTE -- missing semicolon after `}' */

    /* function definition section */
    main()
    {...}

Note that main() has now (inadvertantly) been declared to return
a struct -- a Very Nasty Thing.  The calling sequence may attempt
to reserve space for the return value (a struct) but the startup
code only expects to need space for an int which can cause trouble.

Adam Denton
asd at mtqua.att.com



More information about the Comp.lang.c mailing list