<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 - a pass error, this pass never consider data overflow"
   href="https://bugs.llvm.org/show_bug.cgi?id=40496">40496</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>a pass error, this pass never consider data overflow
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>7.0
          </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>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>witstorm@163.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21395" name="attach_21395" title="source code for error proof">attachment 21395</a> <a href="attachment.cgi?id=21395&action=edit" title="source code for error proof">[details]</a></span>
source code for error proof

Here have a simple program in the attachment.
Example:
#include<stdio.h>
typedef unsigned char X;
//typedef char X;
X Fb(X x, X y){return x + y;}
int main()
{
  auto int ai0,ai1;
  ai0 = 0;
  ai1 = 2147483647;
  ai0 = ai1 + Fb(63, 64);
  printf("%d\n",ai0 == -2147483522);
}
If we use clang to generate .ll file by -O3, we will get wrong .ll file.
The compile command like that: clang a.c -O3 -emit-llvm -S -o aa.ll
we find the pass where did this optimize. There problem is the pass never
consider data overflow for icmp constant fold. And I find the same bug in other
passes, if you need it, just contact me by email(<a href="mailto:witstorm@163.com">witstorm@163.com</a>). 
Run the code, it should print 1.</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>