[LLVMbugs] [Bug 14373] New: Segfault in CodeGenFunction::GetAddrOfBlockDecl when accessing automatic variable from local class

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Nov 18 06:47:17 PST 2012


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

             Bug #: 14373
           Summary: Segfault in CodeGenFunction::GetAddrOfBlockDecl when
                    accessing automatic variable from local class
           Product: clang
           Version: 3.1
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: amanieu at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 9562
  --> http://llvm.org/bugs/attachment.cgi?id=9562
Preprocessed source

$ cat a.cpp
#include <utility>
#include <functional>

template<typename Func>
std::function<void()> exec_func(Func&& f)
{
    struct functor {
        explicit functor(Func&& f): func(std::forward<Func>(f)) {}
        void operator()() const
        {
            f(); // <- error here, should be func() instead. f is a parameter
to exec_func
        }
        Func func;
    };
    return functor(std::forward<Func>(f));
}

int main()
{
    exec_func([]{});
}
$ clang++ -std=c++11 -c a.cpp
0  libLLVM-3.1.so  0x00007ff728e2663f
1  libLLVM-3.1.so  0x00007ff728e26aa9
2  libpthread.so.0 0x00007ff7281651a0
3  clang           0x00000000008167c6
clang::CodeGen::CodeGenFunction::GetAddrOfBlockDecl(clang::VarDecl const*,
bool) + 38
4  clang           0x000000000077dacc
clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) +
1484
5  clang           0x000000000077deda
clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) + 522
6  clang           0x000000000077f66b
clang::CodeGen::CodeGenFunction::EmitCastLValue(clang::CastExpr const*) + 155
7  clang           0x000000000077df25
clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) + 597
8  clang           0x0000000000791dcb
clang::CodeGen::CodeGenFunction::EmitCXXOperatorMemberCallExpr(clang::CXXOperatorCallExpr
const*, clang::CXXMethodDecl const*, clang::CodeGen::ReturnValueSlot) + 75
9  clang           0x000000000077f364
clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*,
clang::CodeGen::ReturnValueSlot) + 500
10 clang           0x0000000000541cc5
11 clang           0x00000000007a8e00
12 clang           0x00000000007ab32d
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 61
13 clang           0x00000000007737bf
clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*,
clang::CodeGen::AggValueSlot, bool) + 191
14 clang           0x0000000000781086
clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) + 70
15 clang           0x00000000007fb01f
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 303
16 clang           0x00000000007fb1ef
clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&,
bool, clang::CodeGen::AggValueSlot) + 239
17 clang           0x00000000007fd822
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) + 210
18 clang           0x00000000007faf13
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 35
19 clang           0x000000000080a9ac
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 492
20 clang           0x0000000000710ca9
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl)
+ 377
21 clang           0x00000000007115dd
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl) + 189
22 clang           0x00000000007137c1
clang::CodeGen::CodeGenModule::EmitDeferred() + 241
23 clang           0x00000000007137d9 clang::CodeGen::CodeGenModule::Release()
+ 9
24 clang           0x000000000070019b
25 clang           0x0000000000827f1d clang::ParseAST(clang::Sema&, bool, bool)
+ 461
26 clang           0x00000000005d7096
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 262
27 clang           0x00000000005c0402
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1042
28 clang           0x00000000005b9a23 cc1_main(char const**, char const**, char
const*, void*) + 9091
29 clang           0x00000000005b6b61 main + 7009
30 libc.so.6       0x00007ff7278b8725 __libc_start_main + 245
31 clang           0x00000000005b753d
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
a.cpp -mrelocation-model static -mdisable-fp-elim -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version
2.23.1 -momit-leaf-frame-pointer -coverage-file a.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.2/../../../../include/c++/4.7.2
-internal-isystem
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../include/c++/4.7.2/x86_64-unknown-linux-gnu
-internal-isystem
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../include/c++/4.7.2/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 /home/amanieu -ferror-limit 19 -fmessage-length 237
-mstackrealign -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak
-fobjc-fragile-abi -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o a.o -x c++ a.cpp 
1.    <eof> parser at end of file
2.    Per-file LLVM IR generation
3.    a.cpp:9:8: Generating code for declaration 'exec_func(<lambda at
a.cpp:20:12> &&)::functor::operator()'
4.    a.cpp:10:3: 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/a-WfH3dy.ii
clang: note: diagnostic msg: /tmp/a-WfH3dy.sh

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