[LLVMbugs] [Bug 7242] New: Assert on valid code: Constant declref with side-effect?!
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu May 27 13:28:51 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=7242
Summary: Assert on valid code: Constant declref with
side-effect?!
Product: clang
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: chris at bubblescope.net
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
Created an attachment (id=4940)
--> (http://llvm.org/bugs/attachment.cgi?id=4940)
Asserting example
The attached code fails with the following assert. This code was reduced from
part of libstdc++.
t.cc:5:9: warning: division by zero is undefined
__max / 0;
^ ~
t.cc:5:9: warning: expression result unused [-Wunused-value]
__max / 0;
~~~~~ ^ ~
Assertion failed: (!Result.HasSideEffects && "Constant declref with
side-effect?!"), function VisitDeclRefExpr, file CGExprScalar.cpp, line 150.
0 clang 0x000000010100d71a PrintStackTrace(void*) + 38
1 clang 0x000000010100dbfa SignalHandler(int) + 312
2 libSystem.B.dylib 0x00007fff8476180a _sigtramp + 26
3 libSystem.B.dylib 0x00007fff5fbfb430 _sigtramp + 3679034432
4 libSystem.B.dylib 0x00007fff847dcef0 __pthread_markcancel + 0
5 clang 0x00000001001b27e1 (anonymous
namespace)::ScalarExprEmitter::VisitDeclRefExpr(clang::DeclRefExpr*) + 153
6 clang 0x00000001001b8374 clang::StmtVisitor<(anonymous
namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) + 3214
7 clang 0x00000001001b69e9 (anonymous
namespace)::ScalarExprEmitter::EmitCastExpr(clang::CastExpr*) + 399
8 clang 0x00000001001b75c3 (anonymous
namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) + 87
9 clang 0x00000001001b76e3 clang::StmtVisitor<(anonymous
namespace)::ScalarExprEmitter,
llvm::Value*>::VisitImplicitCastExpr(clang::ImplicitCastExpr*) + 29
10 clang 0x00000001001b82f7 clang::StmtVisitor<(anonymous
namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) + 3089
11 clang 0x00000001001bb13e (anonymous
namespace)::ScalarExprEmitter::EmitBinOps(clang::BinaryOperator const*) + 58
12 clang 0x00000001001bb1cb (anonymous
namespace)::ScalarExprEmitter::VisitBinDiv(clang::BinaryOperator const*) + 33
13 clang 0x00000001001b7846 clang::StmtVisitor<(anonymous
namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) + 352
14 clang 0x00000001001b8907
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 131
15 clang 0x000000010019278a
clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, llvm::Value*,
bool, bool, bool) + 76
16 clang 0x00000001001fd174
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 756
17 clang 0x00000001001fe865
clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&,
bool, llvm::Value*, bool) + 281
18 clang 0x00000001001fea8f
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) + 179
19 clang 0x00000001001fcece
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 78
20 clang 0x0000000100220d7e
clang::CodeGen::CodeGenFunction::EmitFunctionBody(llvm::SmallVector<std::pair<clang::VarDecl
const*, clang::QualType>, 16u>&) + 146
21 clang 0x0000000100222148
clang::CodeGen::CodeGenFunction::GenerateCode(clang::CodeGen::GlobalDecl,
llvm::Function*) + 1340
22 clang 0x000000010022b8c2
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::CodeGen::GlobalDecl)
+ 688
23 clang 0x000000010022ba6b
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::CodeGen::GlobalDecl)
+ 277
24 clang 0x000000010022bbf5
clang::CodeGen::CodeGenModule::EmitGlobal(clang::CodeGen::GlobalDecl) + 309
25 clang 0x000000010022bec2
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 466
26 clang 0x0000000100245690 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) + 76
27 clang 0x000000010004a95a (anonymous
namespace)::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) + 144
28 clang 0x00000001002562e5 clang::ParseAST(clang::Preprocessor&,
clang::ASTConsumer*, clang::ASTContext&, bool, bool,
clang::CodeCompleteConsumer*) + 440
29 clang 0x000000010006d73e
clang::ASTFrontendAction::ExecuteAction() + 256
30 clang 0x000000010006d83b clang::FrontendAction::Execute() + 239
31 clang 0x000000010005041d
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 785
32 clang 0x0000000100027891 cc1_main(char const**, char const**,
char const*, void*) + 1762
33 clang 0x000000010002ec77 main + 335
34 clang 0x0000000100026710 start + 52
Stack dump:
0. Program arguments: /usr/local/bin/clang -cc1 -triple
x86_64-apple-darwin10.0.0 -emit-obj -mrelax-all -disable-free -main-file-name
t.cc -pic-level 1 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu
core2 -resource-dir /usr/local/lib/clang/2.0 -ferror-limit 19 -fmessage-length
80 -stack-protector 1 -fblocks -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o t.o -x c++ t.cc
1. <eof> parser at end of file
2. t.cc:1:5: LLVM IR generation of declaration 'main'
3. t.cc:1:5: Generating code for declaration 'main'
4. t.cc:2:1: LLVM IR generation of 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