[LLVMbugs] [Bug 17088] New: SIGFPE due to illegal FP optimization
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Sep 3 11:44:59 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=17088
Bug ID: 17088
Summary: SIGFPE due to illegal FP optimization
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: kcc at google.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
<this is fresh clang trunk r189814 on linux x86_64>
% cat fpe.cc
#include <fenv.h>
double zero = 0.0;
#define max(a, b) (a > b ? a : b)
int main() {
feenableexcept(FE_DIVBYZERO);
double z = 3.0 / max(1.0, zero);
return z == 3.0;
}
% clang fpe.cc -lm -g && ./a.out
% gcc fpe.cc -lm -g && ./a.out
% gcc -O1 fpe.cc -lm -g && ./a.out
% clang -O1 fpe.cc -lm -g && ./a.out
Floating point exception (core dumped)
% gdb ./a.out
Reading symbols from /home/kcc/tmp/./a.out...done.
(gdb) r
Starting program: /home/kcc/tmp/./a.out
Program received signal SIGFPE, Arithmetic exception.
0x000000000040057e in main () at fpe.cc:6
6 double z = 3.0 / max(1.0, zero);
(gdb) disassemble
Dump of assembler code for function main():
0x0000000000400560 <+0>: push %rax
0x0000000000400561 <+1>: mov $0x4,%edi
0x0000000000400566 <+6>: callq 0x400460 <feenableexcept at plt>
0x000000000040056b <+11>: movsd 0x12d(%rip),%xmm0 # 0x4006a0
0x0000000000400573 <+19>: movsd 0x200ab5(%rip),%xmm1 # 0x601030
<zero>
0x000000000040057b <+27>: movaps %xmm0,%xmm2
=> 0x000000000040057e <+30>: divsd %xmm1,%xmm2
0x0000000000400582 <+34>: movsd 0x11e(%rip),%xmm3 # 0x4006a8
0x000000000040058a <+42>: ucomisd %xmm1,%xmm3
0x000000000040058e <+46>: seta %al
0x0000000000400591 <+49>: ucomisd %xmm0,%xmm2
0x0000000000400595 <+53>: setnp %cl
0x0000000000400598 <+56>: sete %dl
0x000000000040059b <+59>: and %cl,%dl
0x000000000040059d <+61>: or %al,%dl
0x000000000040059f <+63>: movzbl %dl,%eax
0x00000000004005a2 <+66>: pop %rdx
0x00000000004005a3 <+67>: retq
End of assembler dump.
(gdb)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130903/55940a9d/attachment.html>
More information about the llvm-bugs
mailing list