<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 --- - Local object should have unique address"
   href="http://llvm.org/bugs/show_bug.cgi?id=18557">18557</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Local object should have unique address
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>sam@rfc1149.net
          </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>Created <span class=""><a href="attachment.cgi?id=11905" name="attach_11905" title="Function exhibiting the problem">attachment 11905</a> <a href="attachment.cgi?id=11905&action=edit" title="Function exhibiting the problem">[details]</a></span>
Function exhibiting the problem

[version set as "unspecified" because "3.4" does not appear in the version
selector but this happens in 3.4]

The following function

int f(int recurse, const int old[]) {
  const int a[] = {1, 2, 3, 4};
  if (recurse)
    return f(0, a);
  return a == old;
}

should always return 0 (and does so in GCC):

* If `recurse' is 0, then the newly created object `a' cannot have the same
address as `old'. LLVM makes the comparison and returns the right result, which
is not faulty but may be unnecessary.

* If `recurse' is non-0, then `a' in the first invocation and `a' in the
recursive one cannot be equal, as each automatic variable must have its own
unique address as long as it is alive. Here, LLVM returns 1 without checking
instead of 0. The problem is likely that `a' is stored in `.rodata' (then
discarded as unused) while it should not be shared between `f' can be invoked
recursively and the address of `a' escapes its defining function through the
function call.

Note that this bug was found while signaling a bug on GCC which misses an
optimization when there is no such recursive call:
<a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59863">http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59863</a></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>