<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Simple C program produces different output if compiled with -O1 instead of -O0"
   href="https://bugs.llvm.org/show_bug.cgi?id=44424">44424</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Simple C program produces different output if compiled with -O1 instead of -O0
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>dirk.hoffmann@me.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Test program: main.cpp


#include <stdint.h>
#include <stdio.h>

bool foo(uint32_t x, uint32_t y)
{
        uint32_t z = (uint16_t)x * (uint16_t)y;
        return z & 0x80000000;
}

int main(int argc, char *argv[])
{
        printf("%d\n", foo(0x7FFFF, 0x7FFFF));
}



Compiler: 

Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin18.7.0
Thread model: posix

Output:

<span class="quote">> clang -O0 main.cpp; ./a.out </span >
1

<span class="quote">> clang -O1 main.cpp; ./a.out </span >
0</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>