<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 --- - Non-static const array is wrongly shared among recursions"
   href="http://llvm.org/bugs/show_bug.cgi?id=18538">18538</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Non-static const array is wrongly shared among recursions
          </td>
        </tr>

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

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

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>k_satoda@f2.dion.ne.jp
          </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>The assertion in the following program should never fail because
variables with automatic storage duration in a function should be
created for each recursive invocation, and such distinct objects'
address should not compare equal.

  #include <assert.h>
  #include <stdio.h>
  int f(const int* p)
  {
    const int c[] = {12345,56789};
    assert(p != c);
    if (p == 0) { return f(c); }
    puts("Done.");
    return 0;
  }
  int main()
  {
    f(0);
  }

Clang 3.3 seems violating the rule and causes an assertion failure.
<a href="http://melpon.org/wandbox/permlink/tYmnEVjMNP33nYHr">http://melpon.org/wandbox/permlink/tYmnEVjMNP33nYHr</a>
<span class="quote">> prog.exe: prog.c:6: int f(const int *): Assertion `p != c' failed.</span >

I'm referring WG14 N1570.
<a href="http://www.open-std.org/jtc1/sc22/wg14/www/standards.html">http://www.open-std.org/jtc1/sc22/wg14/www/standards.html</a>

>From 6.2.4 p6:
<span class="quote">> For such an object that does not have a variable length array type, its
> lifetime extends from entry into the block with which it is associated
> until execution of that block ends in any way. (Entering an enclosed
> block or calling a function suspends, but does not end, execution of the
> current block.) If the block is entered recursively, a new instance of
> the object is created each time.</span >

6.5.9 p6
<span class="quote">> Two pointers compare equal if and only if both are null pointers, both
> are pointers to the same object ...</span >

If the variable is not an array, there seems no problem.
<a href="http://melpon.org/wandbox/permlink/uYeR8GbRvuQN3CMC">http://melpon.org/wandbox/permlink/uYeR8GbRvuQN3CMC</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>