Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upExpose `core::intrinsics::unreachable` in stable wrapper #1385
Comments
This comment has been minimized.
This comment has been minimized.
|
Note that it cannot be safe, since the compiler cannot be sure at compile time that it's actually unreachable. But, it's really needed for the sake of performance, since it would allow certain optimizations due to LLVM being sure that it's unwinding safe (which is not the case with |
This comment has been minimized.
This comment has been minimized.
DemiMarie
commented
Dec 17, 2015
|
What about inserting a call to |
This comment has been minimized.
This comment has been minimized.
|
Sounds like it doesn't have the same use case, doesn't help for optimization. |
This comment has been minimized.
This comment has been minimized.
|
@bluss It does not. It's essentially just a less fancy version of |
This comment has been minimized.
This comment has been minimized.
|
If we do expose this we should probably give it a name, such as |
This comment has been minimized.
This comment has been minimized.
|
Matching on an empty enum is the official way to generate an |
This comment has been minimized.
This comment has been minimized.
|
@arielb1 No, it's not. It doesn't help doing any of the optimizations, that core::intrinsics::unreachable do allow. |
This comment has been minimized.
This comment has been minimized.
|
@ticki It does have the same effect on optimizations (experience from my projects), see the crate @arielb1 It would be super cool if you could review the current stable rust impl of unreachable in said crate: https://github.com/reem/rust-unreachable/blob/master/src/lib.rs#L20-L25 My intention is really to put this on safe ground however we do it. Codegen regressions happen. Isn't it much cleaner to just expose the unreachable intrinsic? Rust is low level oriented and has no reason to keep the cool tools locked away. |
This comment has been minimized.
This comment has been minimized.
|
The implementation is fine, although it puts a bit too much stress on the inliner. A simple |
This comment has been minimized.
This comment has been minimized.
|
Cool! @reem see above, we can improve this! |
bluss
added a commit
to bluss/odds
that referenced
this issue
Jan 13, 2016
This comment has been minimized.
This comment has been minimized.
|
@arielb1 no it's not. It's just guaranteed undefined behavior. Why would we want to encourage a hack, versus just having an intrinsic for it? |
This comment has been minimized.
This comment has been minimized.
|
I don't see it as much of a hack. From an operational perspective, all forms of UB are the same. From a performance standpoint, we probably want to document things like that anyway. |
This comment has been minimized.
This comment has been minimized.
|
@arielb1 I mean yes, it's true, all forms of UB are "the same". However, the current solution is far less obvious. edited to not deref a null pointer. |
This comment has been minimized.
This comment has been minimized.
|
dereferencing 0x1 or 0x0 ought to have possibly different implications here, just a sidenote. |
This comment has been minimized.
This comment has been minimized.
|
@bluss it's the same as |
This comment has been minimized.
This comment has been minimized.
main--
commented
Feb 7, 2016
This comment has been minimized.
This comment has been minimized.
|
@main-- ah, I was mistaken. I was going off of something like http://en.chys.info/2010/04/null-can-be-a-valid-address/ |
bluss commentedNov 28, 2015
Best alternative is crate unreachable today, but it may not be able to guarantee exactly the same semantics.
Important for: low level code, performance.