Skip to content

LLVM abort from deref of 0 in a const expression initializing a static #24581

New issue

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

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

Already on GitHub? # to your account

Closed
pnkfelix opened this issue Apr 19, 2015 · 4 comments
Closed

Comments

@pnkfelix
Copy link
Member

(imported from improperly closed bug #17452)

static X: usize = unsafe { *(0 as *const usize) };

fn main() {
    println!("X: {}", X);
}

playpen

This causes LLVM to abort, causing a core dump from rustc. :(

(I suspect we should be more careful, somehow, about handling such things in our const expression evaluator. Not 100% sure how best to resolve this though.)

@pnkfelix pnkfelix added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Apr 19, 2015
@pnkfelix
Copy link
Member Author

(i don't want to tag this as ICE -- that implies to me that we are actually catching this and issuing the ICE message...)

@pnkfelix
Copy link
Member Author

(I suppose I could tag it as both I-ICE and I-crash, though that seems like it does more harm than good w.r.t. the labeling system.)

@ghost
Copy link

ghost commented Apr 19, 2015

I think this issue is a dupe of #13973 so I'm going to close it. @pnkfelix, feel free to reopen if you disagree.

@pnkfelix
Copy link
Member Author

well I'd say that one could probably argue that #13973 should actually compile successfully (and bind BLOCK_UNSAFE_SAFE_PTR to a value that points to the address that corresponds to the number 0xdeadbeef), while this code does not seem like it should compile successfully...

In other words, solving both of these problems may involve a more general solution than solving either independently...

This issue was closed.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant