[LLVMbugs] [Bug 18020] New: Assertion in Codegen with lambdas

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Nov 21 17:41:32 PST 2013


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

            Bug ID: 18020
           Summary: Assertion in Codegen with lambdas
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rtrieu at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Command line:
clang -cc1 -emit-obj -std=c++11 lambda.ii

Code:
class Registerer {
 public:
  Registerer(void (*creator)()) { }
  void test() { }
};

class Base {
 public:
  virtual void Run() { };
};


template<typename Lambda>
class LambdaHandler : public Base {
 public:
  void Run() {
    Lambda()();
  }

  static void Create() {
    new LambdaHandler();
  }

  static Registerer R;

  struct C {
    C() { 
      R.test();
    }
  } c;
};

template <typename T> Registerer LambdaHandler<T>::R(Create);

auto x = []() {
  static auto l1 = []() { return 0; };
  struct Lambda {
    void operator()() const {
      l1();
    }
  };
  return new LambdaHandler<Lambda>();
};

Stack dump:
clang: llvm/tools/clang/lib/CodeGen/CGExpr.cpp:1795: clang::CodeGen::LValue
clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(const clang::DeclRefExpr*):
Assertion `isa<BlockDecl>(CurCodeDecl) && E->refersToEnclosingLocal()' failed.
0  clang           0x0000000001e5cc23 llvm::sys::PrintStackTrace(_IO_FILE*) +
38
1  clang           0x0000000001e5ceaa
2  clang           0x0000000001e5c8ee
3  libpthread.so.0 0x00007fec48834cb0
4  libc.so.6       0x00007fec47c89425 gsignal + 53
5  libc.so.6       0x00007fec47c8cb8b abort + 379
6  libc.so.6       0x00007fec47c820ee
7  libc.so.6       0x00007fec47c82192
8  clang           0x0000000001ff9800
clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) +
1298
9  clang           0x0000000001ff459b
clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) + 481
10 clang           0x0000000001fff1a6
clang::CodeGen::CodeGenFunction::EmitCastLValue(clang::CastExpr const*) + 446
11 clang           0x0000000001ff4a93
clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) + 1753
12 clang           0x000000000201f685
clang::CodeGen::CodeGenFunction::EmitCXXOperatorMemberCallExpr(clang::CXXOperatorCallExpr
const*, clang::CXXMethodDecl const*, clang::CodeGen::ReturnValueSlot) + 143
13 clang           0x0000000001fffd30
clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*,
clang::CodeGen::ReturnValueSlot) + 768
14 clang           0x00000000020281df
15 clang           0x00000000020392fb
16 clang           0x00000000020386cb
17 clang           0x00000000020277e7
18 clang           0x0000000002037489
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 159
19 clang           0x0000000001ff0ce9
clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*,
clang::CodeGen::AggValueSlot, bool) + 101
20 clang           0x0000000001ff0c39
clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) + 127
21 clang           0x0000000001ee59be
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 400
22 clang           0x0000000001ee6065
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot) + 109
23 clang           0x0000000001f013f3
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&,
clang::Stmt const*) + 113
24 clang           0x0000000001f01b27
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 1347
25 clang           0x0000000001f13809
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl)
+ 943
26 clang           0x0000000001f10cd3
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl) + 331
27 clang           0x0000000001f0f77f
clang::CodeGen::CodeGenModule::EmitDeferred() + 341
28 clang           0x0000000001f0c7a9 clang::CodeGen::CodeGenModule::Release()
+ 25
29 clang           0x0000000001e96b85
30 clang           0x0000000001e957ef
31 clang           0x000000000226d72c clang::ParseAST(clang::Sema&, bool, bool)
+ 776
32 clang           0x0000000002166b33 clang::ASTFrontendAction::ExecuteAction()
+ 321
33 clang           0x0000000001e94704 clang::CodeGenAction::ExecuteAction() +
1414
34 clang           0x0000000002166672 clang::FrontendAction::Execute() + 200
35 clang           0x000000000213eaa4
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 720
36 clang           0x0000000001e633de
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1018
37 clang           0x0000000000d035a9 cc1_main(char const**, char const**, char
const*, void*) + 717
38 clang           0x0000000000cfdade main + 786
39 libc.so.6       0x00007fec47c7476d __libc_start_main + 237
40 clang           0x0000000000cfc3d9
Stack dump:
0.    Program arguments: llvm/llvm_build/bin/clang -cc1 -emit-obj -std=c++11
lambda.ii 
1.    <eof> parser at end of file
2.    Per-file LLVM IR generation
3.    lambda.ii:38:10: Generating code for declaration '<anonymous
class>::operator()()::Lambda::operator()'
Aborted (core dumped)

-- 
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/20131122/aa2dea45/attachment.html>


More information about the llvm-bugs mailing list