[cfe-dev] A crash on (late parsed) lambda body with local class.

Enea Zaffanella zaffanella at cs.unipr.it
Mon Oct 1 01:47:29 PDT 2012


The following code shows a crash in (debug mode) clang++:

$ cat crash.cc
class Class {
   void Method(char c = []()->char {
       int d = []()->int {
         struct LateParsedClass {
           int LateParsedMethod() { return 0; }
         };
         return 0;
       }();
       return d;
     }());
};

$ clang++ -fsyntax-only -std=c++11 crash.cc
clang: SemaDecl.cpp:913: void 
clang::Sema::PushDeclContext(clang::Scope*, clang::DeclContext*): 
Assertion `getContainingDC(DC) == CurContext && "The next DeclContext 
should be lexically contained in the current one."' failed.

It seems that, when parsing (LateParsedMethod inside) LateParsedClass, 
the value of Sema.CurContext is still that of the outer class Class, 
while the (lexical) DC of LateParsedClass is that of the inner lambda 
operator() method, hence the assertion failure.

Is this a known bug? Should we file it?

Enea.



More information about the cfe-dev mailing list