I saw a snippet of code on CodeGolf that\'s intended as a compiler bomb, where main
is declared as a huge array. I tried the following (non-bomb) version:
main
is - after compiling - just another symbol in an object file like many others (global functions, global variables, etc).
The linker will link the symbol main
regardless of its type. Indeed, the linker cannot see the type of the symbol at all (he can see, that it isn't in the .text
-section however, but he doesn't care ;))
Using gcc, the standard entry point is _start, which in turn calls main() after preparing the runtime environment. So it will jump to the address of the integer array, which usually will result in a bad instruction, segfault or some other bad behaviour.
This all of course has nothing to do with the C-standard.