[LLVMbugs] [Bug 13015] New: C++11 code that calls a function with struct literal with function call in it makes clang 3.1 segfault

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jun 2 07:16:56 PDT 2012


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

             Bug #: 13015
           Summary: C++11 code that calls a function with struct literal
                    with function call in it makes clang 3.1 segfault
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: compile-fail
          Severity: release blocker
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: rsaarelm+bugzilla at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Compile the attached clang_bug.cpp code with Clang 3.1:

$ cat clang_bug.cpp 

#include <functional>
#include <list>

typedef std::function<float (float)> Func;

struct Record { Func func; int a; };

static int foo() {
  return 1;
}

static void bar(Record record) {}

void add_func(Func func) {
  bar({func, foo()});
}

$ clang -v

clang version 3.1 (branches/release_31)
Target: x86_64-unknown-linux-gnu
Thread model: posix

$ clang -c -std=c++11 clang_bug.cpp 

0  libLLVM-3.1.so  0x00007f4fba2f463f
1  libLLVM-3.1.so  0x00007f4fba2f4aa9
2  libpthread.so.0 0x00007f4fb9633140
3  clang           0x0000000000e30ea0
clang::Decl::castFromDeclContext(clang::DeclContext const*) + 0
4  clang           0x00000000007fe899
clang::CodeGen::CodeGenVTables::needsVTTParameter(clang::GlobalDecl) + 25
5  clang           0x0000000000745ecd
6  clang           0x000000000074635a
clang::CodeGen::CodeGenFunction::EmitCXXDestructorCall(clang::CXXDestructorDecl
const*, clang::CXXDtorType, bool, llvm::Value*) + 58
7  clang           0x0000000000767796
clang::CodeGen::CodeGenFunction::emitDestroy(llvm::Value*, clang::QualType,
void (*)(clang::CodeGen::CodeGenFunction&, llvm::Value*, clang::QualType),
bool) + 662
8  clang           0x000000000074c7df
9  clang           0x000000000074d002
clang::CodeGen::CodeGenFunction::PopCleanupBlock(bool) + 1282
10 clang           0x000000000074dcaa
clang::CodeGen::CodeGenFunction::DeactivateCleanupBlock(clang::CodeGen::EHScopeStack::stable_iterator,
llvm::Instruction*) + 122
11 clang           0x0000000000541293
12 clang           0x0000000000786946
13 clang           0x0000000000787334
clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*,
clang::CodeGen::AggValueSlot, bool) + 196
14 clang           0x000000000077368c
clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*,
clang::CodeGen::AggValueSlot, bool) + 108
15 clang           0x000000000077384a
clang::CodeGen::CodeGenFunction::EmitAnyExprToTemp(clang::Expr const*) + 282
16 clang           0x000000000073743d
clang::CodeGen::CodeGenFunction::EmitCallArg(clang::CodeGen::CallArgList&,
clang::Expr const*, clang::QualType) + 109
17 clang           0x0000000000783ad0
18 clang           0x0000000000777653
clang::CodeGen::CodeGenFunction::EmitCall(clang::QualType, llvm::Value*,
clang::CodeGen::ReturnValueSlot, clang::ConstExprIterator,
clang::ConstExprIterator, clang::Decl const*) + 147
19 clang           0x000000000077f391
clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*,
clang::CodeGen::ReturnValueSlot) + 305
20 clang           0x0000000000541cab
21 clang           0x00000000007a9193
22 clang           0x00000000007ab60d
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 61
23 clang           0x00000000007736df
clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*,
clang::CodeGen::AggValueSlot, bool) + 191
24 clang           0x000000000078119c
clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) + 108
25 clang           0x00000000007fb51f
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 303
26 clang           0x00000000007fb6ef
clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&,
bool, clang::CodeGen::AggValueSlot) + 239
27 clang           0x00000000007fdd40
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) + 240
28 clang           0x00000000007fb413
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 35
29 clang           0x000000000080aecc
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 492
30 clang           0x0000000000710b69
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl)
+ 377
31 clang           0x000000000071151b
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl) + 315
32 clang           0x0000000000711b25
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) + 1445
33 clang           0x000000000071233b
34 clang           0x000000000070057c
35 clang           0x00000000006ffc06
36 clang           0x0000000000828305 clang::ParseAST(clang::Sema&, bool, bool)
+ 309
37 clang           0x00000000005d7206
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 262
38 clang           0x00000000005c0552
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1042
39 clang           0x00000000005b9b73 cc1_main(char const**, char const**, char
const*, void*) + 9091
40 clang           0x00000000005b6c91 main + 7009
41 libc.so.6       0x00007f4fb8d8b455 __libc_start_main + 245
42 clang           0x00000000005b766d
Stack dump:
0.    Program arguments: /usr/bin/clang -cc1 -triple x86_64-unknown-linux-gnu
-emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name
clang_bug.cpp -mrelocation-model static -mdisable-fp-elim -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version
2.22.0.20120323 -momit-leaf-frame-pointer -coverage-file clang_bug.o
-resource-dir /usr/bin/../lib/clang/3.1 -fmodule-cache-path
/var/tmp/clang-module-cache -internal-isystem
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0
-internal-isystem
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/x86_64-unknown-linux-gnu
-internal-isystem
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/bin/../lib/clang/3.1/include -internal-externc-isystem /include
-internal-externc-isystem /usr/include -std=c++11 -fdeprecated-macro
-fdebug-compilation-dir /tmp/bug -ferror-limit 19 -fmessage-length 273
-mstackrealign -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak
-fobjc-fragile-abi -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o clang_bug.o -x c++ clang_bug.cpp 
1.    <eof> parser at end of file
2.    clang_bug.cpp:14:6: LLVM IR generation of declaration 'add_func'
3.    clang_bug.cpp:14:6: Generating code for declaration 'add_func'
4.    clang_bug.cpp:14:26: LLVM IR generation of compound statement ('{}')
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang: note: diagnostic msg: Please submit a bug report to
http://llvm.org/bugs/ and include command line arguments and all diagnostic
information.
clang: note: diagnostic msg: Preprocessed source(s) and associated run
script(s) are located at:
clang: note: diagnostic msg: /tmp/clang_bug-OgfeSh.ii
clang: note: diagnostic msg: /tmp/clang_bug-OgfeSh.sh

$ uname -a
Linux 3.3.6-1-ARCH #1 SMP PREEMPT Sun May 13 10:52:32 CEST 2012 x86_64
GNU/Linux

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list