[llvm-bugs] [Bug 28284] New: Clang crashes when creating a this expression during template instantiation

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 23 18:08:59 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28284

            Bug ID: 28284
           Summary: Clang crashes when creating a this expression during
                    template instantiation
           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: llvm-bugs at lists.llvm.org
    Classification: Unclassified

template <typename T>
struct Foo {
  void (*function)() = [this]() -> void { auto x = s1.s2.ptr; };

  struct S1 {
    struct S2 {
      int* ptr;
    };
    S2 s2;
  };

  S1 s1;
};

void run() { new Foo<int>(); }

>From lib/Sema/TreeTransform.h:
template<typename Derived>
ExprResult
TreeTransform<Derived>::TransformCXXThisExpr(CXXThisExpr *E) {
  QualType T = getSema().getCurrentThisType();

  if (!getDerived().AlwaysRebuild() && T == E->getType()) {
    // Make sure that we capture 'this'.
    getSema().CheckCXXThisCapture(E->getLocStart());
    return E;
  }

  return getDerived().RebuildCXXThisExpr(E->getLocStart(), T, E->isImplicit());
}

In TransformCXXThisExpr, getSema().getCurrentType() returns a empty QualType. 
This is passed to function RebuildCXXThisExpr, which expects the QualType to be
a valid Type.

-- 
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/20160624/6c7073fd/attachment.html>


More information about the llvm-bugs mailing list