[LLVMbugs] [Bug 23358] A Division by Zero does not generate a floating point exception when optimizations are enabled

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 27 13:33:15 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=23358

Emmanuel STAPF <manus at eiffel.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #3 from Emmanuel STAPF <manus at eiffel.com> ---
My concern is not with the standard that says it is an undefined behavior. What
I'm saying is that since I've been using clang, the clang definition of
undefined behavior was to throw a floating point exception (behavior you only
get now with the -O0 optimization). As a user, I expect the behavior of
throwing the exception to remain the same across versions and across various
compiler flags (there might be exception to this rule since certain command
line options changes some behaviors).

I was just highlighting that fact and am hoping you will fix this.

Note that the behavior of throwing an exception is quite common to various C
compilers on the various platforms I've been dealing with.

PS: I kept the `volatile' modifier from the original piece of code I was
debugging but it has actually no bearing in the behavior, so you can update the
code sample to just:

#include <stdio.h>
#include <stdlib.h>

int main () {
    int w = 123;
    int v = (1 / (w - w));

    printf ("Value of v is %d\n", v);
}

Here is the output I'm observing:

: cc -O0 a.c ; ./a.out
Floating exception

: cc -O1 a.c ; ./a.out 
Value of v is 1455093720

-- 
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/20150427/1205a32f/attachment.html>


More information about the llvm-bugs mailing list