<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:baldrick@free.fr" title="Duncan Sands <baldrick@free.fr>"> <span class="fn">Duncan Sands</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - Optimization eliminates an overflow check."
   href="http://llvm.org/bugs/show_bug.cgi?id=16642">bug 16642</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>NEW
           </td>
           <td>RESOLVED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>baldrick@free.fr
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>INVALID
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - Optimization eliminates an overflow check."
   href="http://llvm.org/bugs/show_bug.cgi?id=16642#c1">Comment # 1</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - Optimization eliminates an overflow check."
   href="http://llvm.org/bugs/show_bug.cgi?id=16642">bug 16642</a>
              from <span class="vcard"><a class="email" href="mailto:baldrick@free.fr" title="Duncan Sands <baldrick@free.fr>"> <span class="fn">Duncan Sands</span></a>
</span></b>
        <pre>Overflow when multiplying two signed numbers results in undefined behaviour
according to the C standard.  Thus the compiler is free to introduce code that
fires a nuclear missile, wipes your hard-drive etc, if the multiplication does
in fact overflow.  Fortunately the compiler only inserted code that sets err to
zero in this case, phew!

As overflow when multiplying unsigned numbers does not result in undefined
behaviour you can fix your code by replacing
  r = x * y;
with
  r = (long long)((unsigned long long)x * (unsigned long long)y);</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>