<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - miscompilation on i386 with -fPIC (recent regression)"
   href="http://llvm.org/bugs/show_bug.cgi?id=18029">18029</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>miscompilation on i386 with -fPIC (recent regression)
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>normal
          </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>kcc@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>r195419 on x86 linux: 


% cat b.cc 
#include <stdio.h>
int Bar(int *a) {
  return *a;
}
int Foo(int *a) {
  return Bar(a);
}
int main() {
  int a[7] = {0, 1, 2, 3, 4, 5, 6};
  printf("result: %d (should be 3)\n", Foo(&a[3]));
}

% clang -m32  -O1 b.cc; ./a.out 
result: 3 (should be 3)

% clang  -O1 b.cc; ./a.out 
result: 3 (should be 3)

% clang -m32  -O1 b.cc  -fPIC ; ./a.out 
result: 69485705 (should be 3)


The code looks like this: 
08048400 <_Z3FooPi>:
 8048400:       e8 eb ff ff ff          call   80483f0 <_Z3BarPi>
 8048405:       c3                      ret    

This is obviously wrong, you can not call a function with a parameter like
this on i386, where the parameters are passed via stack. 

This is a very recent regression.</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>