Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pointer addition results in compiler crash #1173

Closed
jwise opened this issue Nov 13, 2011 · 1 comment
Closed

Pointer addition results in compiler crash #1173

jwise opened this issue Nov 13, 2011 · 1 comment
Labels
A-typesystem Area: The type system

Comments

@jwise
Copy link
Contributor

jwise commented Nov 13, 2011

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)

@msullivan
Copy link
Contributor

It looks like the bug is that this typechecks? Adding together pointers (even unsafe ones) doesn't make much sense.

@brson brson closed this as completed in 3cc2641 Nov 13, 2011
bjorn3 added a commit to bjorn3/rust that referenced this issue May 27, 2021
This is necessary to support the cpufeatures crate

Fixes rust-lang#1173
coastalwhite pushed a commit to coastalwhite/rust that referenced this issue Aug 5, 2023
First change them all to unsigned since they're just returning bits, and
then also change them to the smallest-size integer which fits the return
value (`u16` for `i8x16_bitmask` and `u8` for everything else). This
suffers from an LLVM codegen bug for now, but it will hopefully get
fixed in the not too distant future.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system
Projects
None yet
Development

No branches or pull requests

3 participants