<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:manus@eiffel.com" title="Emmanuel STAPF <manus@eiffel.com>"> <span class="fn">Emmanuel STAPF</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED --- - A Division by Zero does not generate a floating point exception when optimizations are enabled"
   href="https://llvm.org/bugs/show_bug.cgi?id=23358">bug 23358</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>RESOLVED
           </td>
           <td>REOPENED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>INVALID
           </td>
           <td>---
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED --- - A Division by Zero does not generate a floating point exception when optimizations are enabled"
   href="https://llvm.org/bugs/show_bug.cgi?id=23358#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED --- - A Division by Zero does not generate a floating point exception when optimizations are enabled"
   href="https://llvm.org/bugs/show_bug.cgi?id=23358">bug 23358</a>
              from <span class="vcard"><a class="email" href="mailto:manus@eiffel.com" title="Emmanuel STAPF <manus@eiffel.com>"> <span class="fn">Emmanuel STAPF</span></a>
</span></b>
        <pre>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</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>