[LLVMbugs] [Bug 21632] New: Assertion failure in CXXNameMangler::mangleFunctionParam with typeid() of VLA

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Nov 21 10:52:35 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=21632

            Bug ID: 21632
           Summary: Assertion failure in
                    CXXNameMangler::mangleFunctionParam with typeid() of
                    VLA
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: warren_ristow at playstation.sony.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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:

  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3639.html

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141121/d9550fbd/attachment.html>


More information about the llvm-bugs mailing list