[LLVMbugs] [Bug 11815] New: Segmentation fault assigning lambda to local with auto

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jan 20 14:40:24 PST 2012


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

             Bug #: 11815
           Summary: Segmentation fault assigning lambda to local with auto
           Product: clang
           Version: 3.0
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: benjamin.kircher at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 7915
  --> http://llvm.org/bugs/attachment.cgi?id=7915
Preprocessed sources of example above

Might be related to lambda expressions and auto type inference (see also bug
#10943 and bug #10818). Not sure. Not even sure that this report is helpful.

Code where it crashes is basically like this:
#include <string>
#include <vector>

void foo() {
    std::vector<std::string> strvec;
    auto bar = [&](const std::string& str) {
        strvec.push_back(str);
    }; // <---- parser is here when crash happens
}

int main(int argc, char** argv) {
    foo();
    return 0;
}

Version:
Debian clang version 3.0-5 (tags/RELEASE_30/final) (based on LLVM 3.0)
Target: i386-pc-linux-gnu
Thread model: posix

Dump:
$ clang++ -std=c++0x -Wall foo.cpp 
foo.cpp:7:26: error: use of undeclared identifier 'str'
        strvec.push_back(str);
                         ^
0  libLLVM-3.0.so.1 0xb7194708
1  libLLVM-3.0.so.1 0xb7194d9c
2                   0xb77f3400 __kernel_sigreturn + 0
3  clang            0x086b8b83
clang::Sema::DeduceAutoType(clang::TypeSourceInfo*, clang::Expr*,
clang::TypeSourceInfo*&) + 35
4  clang            0x08516e1d clang::Sema::AddInitializerToDecl(clang::Decl*,
clang::Expr*, bool, bool) + 2477
5  clang            0x0845e977
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&) + 1623
6  clang            0x084625a4
clang::Parser::ParseDeclGroup(clang::Parser::ParsingDeclSpec&, unsigned int,
bool, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 1300
7  clang            0x08467c23
clang::Parser::ParseSimpleDeclaration(clang::ASTOwningVector<clang::Stmt*,
32u>&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, bool,
clang::Parser::ForRangeInit*) + 803
8  clang            0x08467e42
clang::Parser::ParseDeclaration(clang::ASTOwningVector<clang::Stmt*, 32u>&,
unsigned int, clang::SourceLocation&,
clang::Parser::ParsedAttributesWithRange&) + 178
9  clang            0x08438f9d
clang::Parser::ParseStatementOrDeclaration(clang::ASTOwningVector<clang::Stmt*,
32u>&, bool) + 413
10 clang            0x08436244 clang::Parser::ParseCompoundStatementBody(bool)
+ 1652
11 clang            0x08436ba4
clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) + 164
12 clang            0x084536f9
clang::Parser::ParseFunctionDefinition(clang::Parser::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&) + 1049
13 clang            0x08462306
clang::Parser::ParseDeclGroup(clang::Parser::ParsingDeclSpec&, unsigned int,
bool, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 630
14 clang            0x0844e808
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsingDeclSpec&,
clang::AccessSpecifier) + 216
15 clang            0x0844ef66
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&,
clang::AccessSpecifier) + 742
16 clang            0x084511b6
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::Parser::ParsingDeclSpec*) + 3670
17 clang            0x08451904
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 180
18 clang            0x08424318 clang::ParseAST(clang::Sema&, bool) + 296
19 clang            0x081ffe27 clang::ASTFrontendAction::ExecuteAction() + 103
20 clang            0x082f5712 clang::CodeGenAction::ExecuteAction() + 66
21 clang            0x08200783 clang::FrontendAction::Execute() + 275
22 clang            0x081e6f25
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 325
23 clang            0x081ce926
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1126
24 clang            0x081c729c cc1_main(char const**, char const**, char
const*, void*) + 876
25 clang            0x081c4935 main + 629
26 libc.so.6        0xb61d2e46 __libc_start_main + 230
27 clang            0x081c6ddd
Stack dump:
0.    Program arguments: /usr/bin/clang -cc1 -triple i386-pc-linux-gnu
-emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name
foo.cpp -mrelocation-model static -mdisable-fp-elim -masm-verbose
-mconstructor-aliases -target-cpu pentium4 -target-linker-version
2.21.90.20111025 -momit-leaf-frame-pointer -resource-dir
/usr/bin/../lib/clang/3.0 -fmodule-cache-path /var/tmp/clang-module-cache
-internal-isystem /usr/include/c++/4.6 -internal-isystem
/usr/include/c++/4.6/i486-linux-gnu -internal-isystem
/usr/include/c++/4.6/backward -internal-isystem /usr/local/include
-internal-isystem /usr/bin/../lib/clang/3.0/include -internal-externc-isystem
/usr/include/i486-linux-gnu -internal-externc-isystem /usr/include -Wall
-std=c++0x -fdeprecated-macro -ferror-limit 19 -fmessage-length 179
-fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o
/tmp/foo-RrGMlX.o -x c++ foo.cpp 
1.    foo.cpp:8:6: current parser token ';'
2.    foo.cpp:4:12: parsing function body 'foo'
3.    foo.cpp:4:12: in compound statement ('{}')
clang: error: unable to execute command: Segmentation fault

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