<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 --- - Assertion failure in CXXNameMangler::mangleFunctionParam with typeid() of VLA"
   href="http://llvm.org/bugs/show_bug.cgi?id=21632">21632</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assertion failure in CXXNameMangler::mangleFunctionParam with typeid() of VLA
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>warren_ristow@playstation.sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This is a low-priority issue.

When compiling the following test-case:

  #include <typeinfo>
  #include <stdio.h>

  void foo(int i) {
    char bar[i];

    printf("%s\n", typeid(bar).name());

    return;
  }

with a Release+Asserts build of Clang, an assertion-failure triggers.  A
Release (without Asserts) version compiles it successfully (and without any
warnings).  FTR, in the Release version, 'typeid(bar).name()' returns "Afp__c",
whereas if (for example) the literal 17 had been used for the array (as in
'char bar[17];'), then it returns "A17_c".  I've tested this with a modern
compiler (r222492), but the behavior appears to have existed for a long time.

The assertion-failure is:

  clang: llvm/tools/clang/lib/AST/ItaniumMangle.cpp:3292:
    void (anonymous namespace)::CXXNameMangler::mangleFunctionParam(const
clang::ParmVarDecl *):
    Assertion `parmDepth < FunctionTypeDepth.getDepth()' failed.

Note that the test-case contains ill-formed C++ code.  Specifically, the
typeid() of a Variable-Length array type is ill-formed.  For reference, the
link:

  <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3639.html">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3639.html</a>

contains the following example, which explicitly has a typeid() of a VLA
indicated as being ill-formed:

  void f(std::size_t n)
  {
    int a[n];
    unsigned int x = sizeof(a);            // ill-formed
    const std::type_info& ti = typeid(a);  // ill-formed
    typedef int t[n];                      // ill-formed
  }

g++ considers this to be a user-error (tested with g++ version 4.8.2, but
probably is an error with all relevant versions of g++).  Also tested with
other compilers, and it's considered a user-error.  Likely, the Clang fix will
be to consider it a user-error, and then the ICE will be avoided.</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>