graydon/rust — Issue #1173: Pointer addition results in compiler crash
Author: jwise
Created: 2011-11-13 10:01:07+00:00
State: open

The following sample code causes Rust to crash:

```
fn die() -> *int { (0 as *int) + (0 as *int) }
fn main() { }
```

This crash has the signature:

(gdb) run
Starting program: /usr/local/bin/rustc die.rs
Reading symbols for shared libraries ..+............................................................... done
Assertion failed: (C1->getType()->isIntOrIntVectorTy() && "Tried to create an integer operation on a non-integer type!"), function get, file /Users/joshua/rust/rust/src/llvm/lib/VMCore/Constants.cpp, line 1457.

Program received signal SIGABRT, Aborted.
[Switching to process 40499 thread 0x1e03]
0x939ed9c6 in __pthread_kill ()
(gdb) bt
#0 0x939ed9c6 in __pthread_kill ()
#1 0x91a01f78 in pthread_kill ()
#2 0x00ceebcb in abort ()
#3 0x00ceec44 in __assert_rtn ()
#4 0x00bdd997 in llvm::ConstantExpr::get ()
#5 0x00bde0d2 in llvm::ConstantExpr::getAdd ()
#6 0x00bf2c8f in LLVMBuildAdd ()
#7 0x01141b9b in upcall_call_c_stack_i64 () at ccall.S:26
Previous frame inner to this frame (gdb could not unwind past this frame)