[LLVMbugs] [Bug 8608] New: unheralded conversion to bool

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Nov 15 06:57:20 PST 2010


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

           Summary: unheralded conversion to bool
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: Axel.Naumann at cern.ch
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Hi,

compiling
$ cat expr.cxx:
bool& f(unsigned char& c) { return (bool&)c; }
$ clang -c expr.cxx

crashes:

clang: /build/llvm/src/tools/clang/lib/AST/../../include/clang/AST/Expr.h:2004:
void clang::CastExpr::CheckCastConsistency() const: Assertion
`!getType()->isBooleanType() && "unheralded conversion to bool"' failed.
0  clang           0x000000000140ad6f
1  clang           0x000000000140cfe2
2  libpthread.so.0 0x00007f158cb9bb40
3  libc.so.6       0x00007f158be99ba5 gsignal + 53
4  libc.so.6       0x00007f158be9d6b0 abort + 384
5  libc.so.6       0x00007f158be92a71 __assert_fail + 241
6  clang           0x0000000000c1f0ca
7  clang           0x000000000094eec5
clang::Sema::BuildCStyleCastExpr(clang::SourceLocation, clang::TypeSourceInfo*,
clang::SourceLocation, clang::Expr*) + 309
8  clang           0x00000000009717bb clang::Sema::ActOnCastExpr(clang::Scope*,
clang::SourceLocation, clang::OpaquePtr<clang::QualType>,
clang::SourceLocation, clang::Expr*) + 107
9  clang           0x0000000000867636
clang::Parser::ParseParenExpression(clang::Parser::ParenParseOption&, bool,
clang::OpaquePtr<clang::QualType>, clang::OpaquePtr<clang::QualType>&,
clang::SourceLocation&) + 566
10 clang           0x0000000000863eaa clang::Parser::ParseCastExpression(bool,
bool, bool&, clang::OpaquePtr<clang::QualType>) + 2522
11 clang           0x000000000086458a clang::Parser::ParseCastExpression(bool,
bool, clang::OpaquePtr<clang::QualType>) + 42
12 clang           0x000000000086535e
clang::Parser::ParseAssignmentExpression() + 30
13 clang           0x0000000000865839 clang::Parser::ParseExpression() + 9
14 clang           0x000000000083f4d8
clang::Parser::ParseReturnStatement(clang::AttributeList*) + 136
15 clang           0x000000000083fd3b
clang::Parser::ParseStatementOrDeclaration(clang::ASTOwningVector<clang::Stmt*,
32u>&, bool) + 1051
16 clang           0x00000000008403d4
clang::Parser::ParseCompoundStatementBody(bool) + 404
17 clang           0x0000000000840a16
clang::Parser::ParseFunctionStatementBody(clang::Decl*) + 118
18 clang           0x000000000084a245
clang::Parser::ParseFunctionDefinition(clang::Parser::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&) + 357
19 clang           0x0000000000850ed4
clang::Parser::ParseDeclGroup(clang::Parser::ParsingDeclSpec&, unsigned int,
bool, clang::SourceLocation*) + 1188
20 clang           0x0000000000849149
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsingDeclSpec&,
clang::AttributeList*, clang::AccessSpecifier) + 201
21 clang           0x0000000000849564
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::AttributeList*,
clang::AccessSpecifier) + 372
22 clang           0x000000000084b375
clang::Parser::ParseExternalDeclaration(clang::CXX0XAttributeList,
clang::Parser::ParsingDeclSpec*) + 1333
23 clang           0x000000000084b4c2
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 114
24 clang           0x000000000083380b clang::ParseAST(clang::Sema&, bool) + 139
25 clang           0x0000000000707eb4 clang::CodeGenAction::ExecuteAction() +
68
26 clang           0x0000000000602545
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 357
27 clang           0x00000000005e223c
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1276
28 clang           0x00000000005da1d5 cc1_main(char const**, char const**, char
const*, void*) + 405
29 clang           0x00000000005e11c5 main + 4085
30 libc.so.6       0x00007f158be84d8e __libc_start_main + 254
31 clang           0x00000000005d8a09
Stack dump:
0.    Program arguments: /build/llvm/opt-inst/bin/clang -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
expr.cxx -mrelocation-model static -mdisable-fp-elim -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version
2.20.51 -resource-dir /build/llvm/opt-inst/bin/../lib/clang/2.9 -ferror-limit
19 -fmessage-length 130 -fexceptions -fgnu-runtime -fdiagnostics-show-option
-fcolor-diagnostics -o expr.o -x c++ expr.cxx 
1.    expr.cxx:1:44: current parser token ';'
2.    expr.cxx:1:27: parsing function body 'f'
3.    expr.cxx:1:27: in compound statement ('{}')
clang: error: unable to execute command: Aborted
clang: error: clang frontend command failed due to signal 1 (use -v to see
invocation)

yes, ugly code, but an ICE is still a bit harsh :-) Can you help?

Cheers, Axel.

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