Live data from Hacker News

The Shortest Crashing C Program

llbit.se

1–10 of 94 posts

Re: The Shortest Crashing C Program

#3
This reminds me of "A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux" [1]. The author tries to create the smallest possible elf executable possible. You would think it'd be easy... :) go read it. Very cool!

[1] http://www.muppetlabs.com/~breadbox/software/tiny/teensy.htm...

Re: The Shortest Crashing C Program

#5
I'm not convinced this is a C89 program. It is only an "accident" that the linker doesn't know about types.

I find it hard to believe that the C89 spec states that an integer called "main" is to be considered the main function, and suspect this is undefined behaviour (though I've not checked).

Re: The Shortest Crashing C Program

#7
It depends on the definition. You can do better than this if you define a valid C program as anything that passes though the C compiler and generates an executable. Behold the zero length program:

$ touch a.c

$ gcc -c a.c

$ ld a.o

ld: warning: cannot find entry symbol _start; defaulting to 0000000000400078

$ ./a.out

Segmentation fault

Re: The Shortest Crashing C Program

#10
post #5

I'm not convinced this is a C89 program. It is only an "accident" that the linker doesn't know about types. I find it hard to believe that the C89 spec states that an integer called "main" is to be considered the main function, and suspect this is undefined behaviour (though I've not checked).

It can't be a valid C89 program. On many Harvard architecture based microprocessors data pointers and code pointers have differing size.
Post reply on HN