[LLVMbugs] [Bug 8135] New: Clang++ crashes on case ranges (GNU extension)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Sep 13 05:48:16 PDT 2010


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

           Summary: Clang++ crashes on case ranges (GNU extension)
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: ggreif at gmail.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Compile below snippet:

#######################################
enum E {
    one,
    two,
    three,
    four
};


int test(enum E e) 
{
    switch (e) 
    {
        case one:
            return 7;
        case two ... two + 1:
            return 42;
        case four:
            return 25;
        default:
            return 0;
    }
}
#######################################

/// invoke as:
/// Debug+Asserts/bin/clang++ -c case-range.c
/// does not crash with
/// Debug+Asserts/bin/clang -c case-range.c

It asserts:

$ Debug+Asserts/bin/clang++ -c ~/case-range.c
clang++: warning: treating 'c' input as 'c++' when in C++ mode, this behavior
is deprecated [-Wdeprecated]
clang++: /home/ggreif/llvm/include/llvm/ADT/APSInt.h:129: bool
llvm::APSInt::operator<=(const llvm::APSInt&) const: Assertion `IsUnsigned ==
RHS.IsUnsigned && "Signedness mismatch!"' failed.
0  clang++         0x0000000001fb86a4
1  clang++         0x0000000001fb84cc
2  libpthread.so.0 0x0000003ed7e0eb10
3  libc.so.6       0x0000003ed7230265 gsignal + 53
4  libc.so.6       0x0000003ed7231d10 abort + 272
5  libc.so.6       0x0000003ed72296e6 __assert_fail + 246
6  clang++         0x0000000001539b83 llvm::APSInt::operator<=(llvm::APSInt
const&) const + 67
7  clang++         0x000000000156f7c1
clang::Sema::ActOnFinishSwitchStmt(clang::SourceLocation, clang::Stmt*,
clang::Stmt*) + 5901
8  clang++         0x0000000001401aa4
clang::Parser::ParseSwitchStatement(clang::AttributeList*) + 872
9  clang++         0x00000000013fff1e
clang::Parser::ParseStatementOrDeclaration(bool) + 1482
10 clang++         0x0000000001400ce0
clang::Parser::ParseCompoundStatementBody(bool) + 208
11 clang++         0x0000000001404052
clang::Parser::ParseFunctionStatementBody(clang::Decl*) + 136
12 clang++         0x00000000014099f9
clang::Parser::ParseFunctionDefinition(clang::Parser::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&) + 795
13 clang++         0x000000000140edb5
clang::Parser::ParseDeclGroup(clang::Parser::ParsingDeclSpec&, unsigned int,
bool, clang::SourceLocation*) + 371
14 clang++         0x000000000140965a
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsingDeclSpec&,
clang::AttributeList*, clang::AccessSpecifier) + 764
15 clang++         0x00000000014096b6
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::AttributeList*,
clang::AccessSpecifier) + 62
16 clang++         0x000000000140914c
clang::Parser::ParseExternalDeclaration(clang::CXX0XAttributeList,
clang::Parser::ParsingDeclSpec*) + 1634
17 clang++         0x0000000001408a5e
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 226
18 clang++         0x00000000013f4eef clang::ParseAST(clang::Sema&, bool) + 219
19 clang++         0x00000000011d46bd clang::ASTFrontendAction::ExecuteAction()
+ 201
20 clang++         0x00000000012cc0a7 clang::CodeGenAction::ExecuteAction() +
813
21 clang++         0x00000000011d43c2 clang::FrontendAction::Execute() + 258
22 clang++         0x00000000011c277b
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 641
23 clang++         0x00000000011802ae
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 696
24 clang++         0x00000000011750de cc1_main(char const**, char const**, char
const*, void*) + 732
25 clang++         0x000000000117ca8a main + 408
26 libc.so.6       0x0000003ed721d994 __libc_start_main + 244
27 clang++         0x0000000001174919
Stack dump:
0.      Program arguments: Debug+Asserts/bin/clang++ -cc1 -triple
x86_64-unknown-linux-gnu -S -disable-free -main-file-name case-range.c
-mrelocation-model static -mdisable-fp-elim -mconstructor-aliases
-munwind-tables -target-cpu x86-64 -target-linker-version 2.17.50.0.6
-resource-dir Debug+Asserts/lib/clang/2.9 -ferror-limit 19 -fmessage-length 126
-fexceptions -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o
/tmp/cc-PeCbYu.s -x c++ /home/ggreif/case-range.c 
1.      /home/ggreif/case-range.c:22:1: current parser token '}'
2.      /home/ggreif/case-range.c:10:1: parsing function body 'test'
3.      /home/ggreif/case-range.c:10:1: in compound statement ('{}')
clang++: error: clang frontend command failed due to signal 6 (use -v to see
invocation)

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