[llvm-bugs] [Bug 28184] New: clang crashes on valid C++ code having ternary expression with throw: Assertion `getOperand(0)->getType() == cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 17 22:31:59 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28184

            Bug ID: 28184
           Summary: clang crashes on valid C++ code having ternary
                    expression with throw: Assertion
                    `getOperand(0)->getType() ==
                    cast<PointerType>(getOperand(1)->getType())->getElemen
                    tType() && "Ptr must be a pointer to Val type!"'
                    failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

The current clang trunk crashes when compiling the following C++ test case on
x86_64-linux-gnu in both 32-bit and 64-bit modes. 

This is a regression from 3.8.x and has to do with DR 1560. 


$ clang++ -v
clang version 3.9.0 (trunk 272993)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$
$ clang++-3.8 small.cpp
small.cpp:7:11: error: cannot compile this l-value expression yet
  (true ? throw 0 : a) = 0;
          ^~~~~~~
1 error generated.
$
$ clang++ small.cpp
small.cpp:7:11: error: cannot compile this l-value expression yet
  (true ? throw 0 : a) = 0;
          ^~~~~~~
clang-3.9: /tmp/llvm-builder/llvm-source-trunk/lib/IR/Instructions.cpp:1410:
void llvm::StoreInst::AssertOK(): Assertion `getOperand(0)->getType() ==
cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a
pointer to Val type!"' failed.
#0 0x0000000001d1b425 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1d1b425)
#1 0x0000000001d192b6 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-3.9+0x1d192b6)
#2 0x0000000001d194d4 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-3.9+0x1d194d4)
#3 0x00007f47134af340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f47126cdcc9 gsignal
/build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f47126d10d8 abort
/build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f47126c6b86 __assert_fail_base
/build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f47126c6c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x000000000195fecd llvm::StoreInst::AssertOK()
(/usr/local/clang-trunk/bin/clang-3.9+0x195fecd)
#9 0x00000000019600d3 llvm::StoreInst::StoreInst(llvm::Value*, llvm::Value*,
bool, unsigned int, llvm::Instruction*)
(/usr/local/clang-trunk/bin/clang-3.9+0x19600d3)
#10 0x0000000001ff415e
clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*,
clang::CodeGen::Address, bool, clang::QualType,
clang::CodeGen::AlignmentSource, llvm::MDNode*, bool, clang::QualType, unsigned
long, bool) (/usr/local/clang-trunk/bin/clang-3.9+0x1ff415e)
#11 0x0000000001ff45ba
clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*,
clang::CodeGen::LValue, bool) (/usr/local/clang-trunk/bin/clang-3.9+0x1ff45ba)
#12 0x00000000020015d6
clang::CodeGen::CodeGenFunction::EmitStoreThroughLValue(clang::CodeGen::RValue,
clang::CodeGen::LValue, bool) (/usr/local/clang-trunk/bin/clang-3.9+0x20015d6)
#13 0x00000000020073aa
clang::CodeGen::CodeGenFunction::EmitBinaryOperatorLValue(clang::BinaryOperator
const*) (/usr/local/clang-trunk/bin/clang-3.9+0x20073aa)
#14 0x0000000002000a9e clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr
const*) (/usr/local/clang-trunk/bin/clang-3.9+0x2000a9e)
#15 0x0000000002000ba8
clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2000ba8)
#16 0x0000000001eaa6ec clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*) (/usr/local/clang-trunk/bin/clang-3.9+0x1eaa6ec)
#17 0x0000000001eab3df
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/usr/local/clang-trunk/bin/clang-3.9+0x1eab3df)
#18 0x0000000001ed12f2
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&,
clang::Stmt const*) (/usr/local/clang-trunk/bin/clang-3.9+0x1ed12f2)
#19 0x0000000001edba4e
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1edba4e)
#20 0x0000000001efcc21
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/usr/local/clang-trunk/bin/clang-3.9+0x1efcc21)
#21 0x0000000001f0d381
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/usr/local/clang-trunk/bin/clang-3.9+0x1f0d381)
#22 0x0000000001f0e299
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
(/usr/local/clang-trunk/bin/clang-3.9+0x1f0e299)
#23 0x0000000001f0e96d
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) [clone
.part.6217] (/usr/local/clang-trunk/bin/clang-3.9+0x1f0e96d)
#24 0x000000000248b97b (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
(/usr/local/clang-trunk/bin/clang-3.9+0x248b97b)
#25 0x000000000248628c
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(/usr/local/clang-trunk/bin/clang-3.9+0x248628c)
#26 0x00000000027f0676 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x27f0676)
#27 0x0000000002486d3e clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-3.9+0x2486d3e)
#28 0x00000000021977fe clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-3.9+0x21977fe)
#29 0x000000000216d266
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-3.9+0x216d266)
#30 0x00000000022245c2
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-3.9+0x22245c2)
#31 0x0000000000af0548 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-3.9+0xaf0548)
#32 0x0000000000aa46dc main (/usr/local/clang-trunk/bin/clang-3.9+0xaa46dc)
#33 0x00007f47126b8ec5 __libc_start_main
/build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#34 0x0000000000aec5b4 _start (/usr/local/clang-trunk/bin/clang-3.9+0xaec5b4)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-3.9 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
small.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb
-resource-dir /usr/local/clang-trunk/bin/../lib/clang/3.9.0 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/3.9.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir /data2 -ferror-limit 19 -fmessage-length 278
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o /tmp/small-f88da6.o -x c++ small.cpp
1.      <eof> parser at end of file
2.      small.cpp:4:5: LLVM IR generation of declaration 'main'
3.      small.cpp:4:5: Generating code for declaration 'main'
clang-3.9: error: unable to execute command: Aborted (core dumped)
clang-3.9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.9.0 (trunk 272993)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
clang-3.9: 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-3.9: note: diagnostic msg:
********************

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

********************
$


----------------------------------------------------


int a;
bool b = true;

int main ()
{ 
  // but why this is okay: (b ? throw 0 : a) = 0;
  (true ? throw 0 : a) = 0;
  return 0;
}

-- 
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/20160618/6ead7c21/attachment.html>


More information about the llvm-bugs mailing list