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

Douglas Gregor dgregor at apple.com
Mon Oct 1 08:52:59 PDT 2012


On Oct 1, 2012, at 1:47 AM, Enea Zaffanella <zaffanella at cs.unipr.it> wrote:

> 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?


Please file.

	- Doug



More information about the cfe-dev mailing list