Mail Archives: djgpp/1993/07/06/23:09:40
gcc -O does eliminate dead code, and has done so for a very long
time. I compiled this with gcc -O2 -m486 -S, with gcc ~2.3.3,
although I haven't tried it with the latest gcc distributed with
djgpp.
#include <stdio.h>
int
main (int argc, char *argv[])
{
if (0)
fprintf (stderr, "This shouldn't exist.\n");
return 0;
}
and got this assembly:
.file "foo.c"
gcc2_compiled.:
___gnu_compiled_c:
.text
LC0:
.ascii "This shouldn't exist.\12\0"
.align 4
.globl _main
_main:
pushl %ebp
movl %esp,%ebp
call ___main
xorl %eax,%eax
movl %ebp,%esp
popl %ebp
ret
What version of gcc are you using?
-Mat
- Raw text -