fb39ca4 / picoc

Automatically exported from code.google.com/p/picoc
0 stars 0 forks source link

Incorrect return type causes a crash #105

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
#include <stdlib.h>

double main()
{
    return 42;
}

Causes a segmentation fault.

Original issue reported on code.google.com by zik.sale...@gmail.com on 27 Jul 2010 at 6:43

GoogleCodeExporter commented 8 years ago
I didn't bother to see why this happens, but a simple fix is to enforce a VOID 
or INT return type. 
Anything other return type make no sense and isn't valid C code anyway.

Original comment by duncan.f...@gmail.com on 3 Aug 2010 at 11:31

GoogleCodeExporter commented 8 years ago
Actually you should enforce the entire definition of main.
I.e. only allow 0 or 2 arguments and if there are 2 arguments they must be type 
INT and CharPtrPtr.

Original comment by duncan.f...@gmail.com on 4 Aug 2010 at 1:33

GoogleCodeExporter commented 8 years ago
Now fixed in r517.

Original comment by zik.sale...@gmail.com on 12 Feb 2011 at 10:57