I created two C programs
Program 1
int main() { }
Program 2
int main() { //Some Harmless comments }
AFAIK, when compiling, the compiler(gcc) should ignore the comments and redundant whitepaces, and hence the output must be similar.
But when I checked the md5sums of the output binaries, they don't match. I also tried compiling with optimisation -O3
and -Ofast
but they still didn't match.
What is happening here?
EDIT: the exact commands and there md5sums are(t1.c is program 1 and t2.c is program 2)
gcc ./t1.c -o aaa
gcc ./t2.c -o bbb
98c1a86e593fd0181383662e68bac22f aaa
c10293cbe6031b13dc6244d01b4d2793 bbb
gcc ./t2.c -Ofast -o bbb
gcc ./t1.c -Ofast -o aaa
2f65a6d5bc9bf1351bdd6919a766fa10 aaa
c0bee139c47183ce62e10c3dbc13c614 bbb
gcc ./t1.c -O3 -o aaa
gcc ./t2.c -O3 -o bbb
564a39d982710b0070bb9349bfc0e2cd aaa
ad89b15e73b26e32026fd0f1dc152cd2 bbb
And yes, md5sums match across multiple compilations with same flags.
BTW my system is gcc (GCC) 5.2.0
and Linux 4.2.0-1-MANJARO #1 SMP PREEMPT x86_64 GNU/Linux