[LLVMbugs] [Bug 21484] New: Clang crashes on lambdas with arguments of invalid types derived from template arguments

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Nov 4 18:00:59 PST 2014


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

            Bug ID: 21484
           Summary: Clang crashes on lambdas with arguments of invalid
                    types derived from template arguments
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rtrieu at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Code:
template<class T>
void bar(T t) {
  auto x = [](typename T::ns::type &k) {}; 
}

class S {};

void foo() {
  bar(5);
  bar(S());
}

Commandline:
clang -std=c++11 test.cc

Error:
bar(5) produces:
test.cc:3:24: error: type 'int' cannot be used prior to '::' because it has no
      members
  auto x = [](typename T::ns::type &k) {};
                       ^
test.cc:9:3: note: in instantiation of function template specialization
      'bar<int>' requested here
  bar(5);
  ^

bar(S()) [with bar(5) commented out] produces:
test.cc:3:27: error: no member named 'ns' in 'S'
  auto x = [](typename T::ns::type &k) {};
                       ~~~^
test.cc:10:3: note: in instantiation of function template specialization
      'bar<S>' requested here
  bar(S());
  ^

Assertion:
clang-3.6: ../tools/clang/lib/Sema/TypeLocBuilder.h:106: clang::TypeSourceInfo
*clang::TypeLocBuilder::getTypeSourceInfo(clang::ASTContext &,
clang::QualType): Assertion `T == LastTy && "type doesn't match last type
pushed!"' failed.

QualType T in the assertion is a null QualType.

I suspect that TransformLambdaExpr (which calls getTypeSoucreInfo at lint 9017
and triggers the assertion) is not handling invalid types properly along all
paths.

-- 
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/20141105/8d770d24/attachment.html>


More information about the llvm-bugs mailing list