[LLVMbugs] [Bug 20135] New: Pointer cast from standard address_space to non-standard one causes assert

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jun 26 10:49:03 PDT 2014


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

            Bug ID: 20135
           Summary: Pointer cast from standard address_space to
                    non-standard one causes assert
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dmcdb at trialsoftware.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12706
  --> http://llvm.org/bugs/attachment.cgi?id=12706&action=edit
preprocessed source & associated run script

Clang crashes when a pointer value of the standard address space is casted into
non-standard address space and assigned to a pointer variable of a non-standard
address space.

This occurs only when the source file has .cpp extension. The same source file
with .c extension compiles ok.

Crash backtrace is as follows:

clang: /home/nhaketa/src/llvm-3.5.x/llvm/lib/IR/Instructions.cpp:1085: void
llvm::StoreInst::AssertOK(): Assertion `getOperand(0)->getType() ==
cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a
pointer to Val type!"' failed.
0  clang           0x000000000209afa2 llvm::sys::PrintStackTrace(_IO_FILE*) +
34
1  clang           0x000000000209a844
2  libpthread.so.0 0x0000003a18e0f710
3  libc.so.6       0x0000003a18a32925 gsignal + 53
4  libc.so.6       0x0000003a18a34105 abort + 373
5  libc.so.6       0x0000003a18a2ba4e
6  libc.so.6       0x0000003a18a2bb10 __assert_perror_fail + 0
7  clang           0x0000000002010ccc llvm::StoreInst::AssertOK() + 140
8  clang           0x000000000093613b
clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*, llvm::Value*,
bool, unsigned int, clang::QualType, llvm::MDNode*, bool, clang::QualType,
unsigned long) + 219
9  clang           0x00000000009365a1
clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*,
clang::CodeGen::LValue, bool) + 65
10 clang           0x0000000000939a9b
clang::CodeGen::CodeGenFunction::EmitStoreThroughLValue(clang::CodeGen::RValue,
clang::CodeGen::LValue, bool) + 1179
11 clang           0x00000000009435de
clang::CodeGen::CodeGenFunction::EmitBinaryOperatorLValue(clang::BinaryOperator
const*) + 734
12 clang           0x000000000093f4e5
clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) + 1029
13 clang           0x000000000093fb18
clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) + 24
14 clang           0x0000000000859bcf
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 255
15 clang           0x000000000085a1ff
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot) + 79
16 clang           0x000000000086af74
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&,
clang::Stmt const*) + 276
17 clang           0x000000000086cb84
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 836
18 clang           0x000000000088d9e4
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) + 468
19 clang           0x000000000088edb7
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) + 503
20 clang           0x00000000008919cd
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) + 1677
21 clang           0x0000000000892320
22 clang           0x00000000008233b3
23 clang           0x000000000081f18c
24 clang           0x00000000009d5d0e clang::ParseAST(clang::Sema&, bool, bool)
+ 302
25 clang           0x000000000082075b clang::CodeGenAction::ExecuteAction() +
59
26 clang           0x0000000000683246 clang::FrontendAction::Execute() + 118
27 clang           0x000000000065ebd0
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 304
28 clang           0x0000000000646d33
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2115
29 clang           0x000000000063d858 cc1_main(char const**, char const**, char
const*, void*) + 968
30 clang           0x0000000000644192 main + 1362
31 libc.so.6       0x0000003a18a1ed1d __libc_start_main + 253
32 clang           0x000000000063cd65
Stack dump:
0.    Program arguments: /usr/local/bin/clang -cc1 -triple
x86_64-unknown-linux-gnu -emit-llvm -disable-free -main-file-name foo.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.20.51.0.2 -coverage-file
/home/nhaketa/src/clang-test/foo.ll -resource-dir
/usr/local/bin/../lib/clang/3.5.0 -internal-isystem
/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0
-internal-isystem
/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/x86_64-unknown-linux-gnu
-internal-isystem
/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/backward
-internal-isystem
/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/x86_64-unknown-linux-gnu/c++/4.9.0
-internal-isystem /usr/local/include -internal-isystem
/usr/local/bin/../lib/clang/3.5.0/include -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir /home/nhaketa/src/clang-test -ferror-limit 19
-fmessage-length 209 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -o foo.ll -x c++ foo.cpp 
1.    <eof> parser at end of file
2.    foo.cpp:4:6: LLVM IR generation of declaration 'func'
3.    foo.cpp:4:6: Generating code for declaration 'func'
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.5.0 (trunk 211489)
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/foo-2b54c7.ii
clang: note: diagnostic msg: /tmp/foo-2b54c7.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/20140626/21dec057/attachment.html>


More information about the llvm-bugs mailing list