<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 - Clang produces incorrect code at -O0"
   href="https://bugs.llvm.org/show_bug.cgi?id=34381">34381</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang produces incorrect code at -O0
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>Vsevolod.Livinskij@frtk.ru
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang produces wrong-code with -O0.
<span class="quote">>$ cat driver.cpp </span >
#include <stdio.h>
extern const signed char var_11;
extern const unsigned int var_21;
extern const signed char var_29;
extern signed char var_370;
extern unsigned int var_390;

const signed char var_11 = 97;
const unsigned int var_21 = 3536697529U;
const signed char var_29 = 20;
signed char var_370 = 16;
unsigned int var_390 = 1082014357U;

extern void foo ();

int main () {
    foo ();
    printf("%llu\n", var_390);
    return 0;
}

<span class="quote">>$ cat func.cpp </span >
extern const signed char var_11;
extern const unsigned int var_21;
extern const signed char var_29;
extern signed char var_370;
extern unsigned int var_390;

void foo() {
  var_390 = !char((var_21 < -var_29) + ~0);
  var_370 = short(var_11);
}

<span class="quote">>$ clang++ -O1 driver.cpp func.cpp ; ./a.out </span >
1
<span class="quote">>$ clang++ -O0 driver.cpp func.cpp ; ./a.out </span >
0

clang version 6.0.0 (trunk 311997)</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>