[LLVMbugs] [Bug 21531] New: crash on parameter pack in switch case

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Nov 11 09:46:34 PST 2014


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

            Bug ID: 21531
           Summary: crash on parameter pack in switch case
           Product: clang
           Version: 3.5
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rhainin1 at binghamton.edu
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 13318
  --> http://llvm.org/bugs/attachment.cgi?id=13318&action=edit
cpp post-processed

When using a parameter pack in a switch case (invalid code).  clang crashes. 
The code to produce:

template <int... Is>
int f(int i) {
    switch (i) {
        case Is:
            return 0;
    }
}

int main() {
    f<1,2,3>(1);
}


The backtrace:
expandcase.cpp:4:14: error: expression contains unexpanded parameter pack 'Is'
        case Is:
             ^~
0  clang           0x00000000026f1cd2 llvm::sys::PrintStackTrace(_IO_FILE*) +
34
1  clang           0x00000000026f1574
2  libpthread.so.0 0x00007fb841892030
3  clang           0x0000000000fadf5f
clang::Sema::ActOnFinishSwitchStmt(clang::SourceLocation, clang::Stmt*,
clang::Stmt*) + 847
4  clang           0x0000000000d26b98
clang::Parser::ParseSwitchStatement(clang::SourceLocation*) + 536
5  clang           0x0000000000d2452b
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&)
+ 2075
6  clang           0x0000000000d24a98
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*) + 120
7  clang           0x0000000000d27a66
clang::Parser::ParseCompoundStatementBody(bool) + 1846
8  clang           0x0000000000d29b46
clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) + 198
9  clang           0x0000000000cc3abd
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) +
1277
10 clang           0x0000000000d34da7
clang::Parser::ParseSingleDeclarationAfterTemplate(unsigned int,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 3831
11 clang           0x0000000000d35a53
clang::Parser::ParseTemplateDeclarationOrSpecialization(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 963
12 clang           0x0000000000d35cfa
clang::Parser::ParseDeclarationStartingWithTemplate(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 138
13 clang           0x0000000000cdbf14
clang::Parser::ParseDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, unsigned
int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 612
14 clang           0x0000000000cc4cb1
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 337
15 clang           0x0000000000cc5390
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 448
16 clang           0x0000000000cbcac0 clang::ParseAST(clang::Sema&, bool, bool)
+ 400
17 clang           0x0000000000b3102b clang::CodeGenAction::ExecuteAction() +
59
18 clang           0x00000000009a2d26 clang::FrontendAction::Execute() + 118
19 clang           0x000000000097db70
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 320
20 clang           0x0000000000966b63
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2115
21 clang           0x0000000000960118 cc1_main(char const**, char const**, char
const*, void*) + 1384
22 clang           0x000000000093a962 main + 1362
23 libc.so.6       0x00007fb840746ead __libc_start_main + 253
24 clang           0x000000000095f4ed
Stack dump:
0.    Program arguments:
/import/linux/home/kchiu/packages/linux-x86_64/llvm-3.5.0/bin/clang -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name expandcase.cpp -mrelocation-model static -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -target-linker-version 2.24
-dwarf-column-info -resource-dir
/import/linux/home/kchiu/packages/linux-x86_64/llvm-3.5.0/bin/../lib/clang/3.5.0
-internal-isystem
/home/kchiu/packages/linux-x86_64/gcc-4.9.1/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/../../../../include/c++/4.9.1
-internal-isystem
/home/kchiu/packages/linux-x86_64/gcc-4.9.1/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/../../../../include/c++/4.9.1/x86_64-unknown-linux-gnu
-internal-isystem
/home/kchiu/packages/linux-x86_64/gcc-4.9.1/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/../../../../include/c++/4.9.1/backward
-internal-isystem /usr/local/include -internal-isystem
/import/linux/home/kchiu/packages/linux-x86_64/llvm-3.5.0/bin/../lib/clang/3.5.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-std=c++11 -fdeprecated-macro -fdebug-compilation-dir
/import/linux/home/rhainin1 -ferror-limit 19 -fmessage-length 0 -mstackrealign
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o
/tmp/expandcase-03aba5.o -x c++ expandcase.cpp 
1.    expandcase.cpp:7:1: current parser token '}'
2.    expandcase.cpp:2:14: parsing function body 'f'
3.    expandcase.cpp:2:14: in 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 version 3.5.0 (tags/RELEASE_350/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/expandcase-365a30.cpp
clang: note: diagnostic msg: /tmp/expandcase-365a30.sh
clang: note: diagnostic msg: 

********************

-- 
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/20141111/e9d658f4/attachment.html>


More information about the llvm-bugs mailing list