http://stackoverflow.com/questions/13855582/gcc-outputs-very-large-executable-for-mersenne-program
This is a copy of a small C program that prints the largest(?) known Mersenne prime from http://bellard.org/mersenne.html. The file size is slightly larger than the 438 bytes mentioned on the web page, probably because of line breaks.
The original version generates a very large object file because of the large initialized static array.
By removing the initialization and replacing it with an assignment
to the 0th element in main
, the entire array is no longer allocated
in the object file, but the program still produces the same output.
Note that nothing in the C standard says anything about the size of object files. This compile-time behavior is specific to gcc -- and probably to a number of other compilers that behave similarly.