Hi,

Division by zero is undefined. We chose to keep it:

http://gcc.gnu.org/ml/gcc-patches/2001-06/msg01068.html

But now gcc seems to optimize it away. For the following function:

$ cat t.c
#include <limits.h>
void foo (int rc)
{
 int x = rc / INT_MAX;
 x = 4 / x;
}

$ gcc -O2 -S t.c
$ cat t.s
       .file   "t.c"
       .text
       .p2align 4,,15
.globl foo
       .type   foo, @function
foo:
       pushl   %ebp
       movl    %esp, %ebp
       popl    %ebp
       ret
       .size   foo, .-foo
       .ident  "GCC: (GNU) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)"
       .section        .note.GNU-stack,"",@progbits

Does we now choose to optimize it away now?


Jie

Reply via email to