Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] C puzzle



>>>>> "JG" == Josh Glover <jmglov@example.com> writes:

    JG> bruno raoult wrote:
    >> 
    >> PS. BTW, what is this "smallest C program", which compiles with
    >> no options?

    JG> The canonical answer is:

    JG> main(){}

What about the one which always crashes?

The following program contains 25 characters, uses no library
functions and segfaults when run:

main(){((void(*)())0)();}

I used the following line to test the code (may save you some typing):

$ echo 'main(){((void(*)())0)();}' > f.c; gcc -o f f.c; ./f; rm f.c f
Segmentation fault

Viktor


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links