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

Documentation for unreachable macro incorrectly describes unreachable_unchecked #60754

Closed
nuew opened this issue May 12, 2019 · 0 comments · Fixed by #61084
Closed

Documentation for unreachable macro incorrectly describes unreachable_unchecked #60754

nuew opened this issue May 12, 2019 · 0 comments · Fixed by #61084
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@nuew
Copy link

nuew commented May 12, 2019

The documentation for the unreachable! macro says:

If the determination that the code is unreachable proves incorrect, the program immediately terminates with a panic!. The function unreachable_unchecked, which belongs to the std::hint module, informs the compiler to optimize the code out of the release version entirely.

This is incorrect; while building in release (and thus with optimizations) certainly makes the compiler more likely to exploit unreachable_unchecked, it is still UB to reach it without optimizations enabled, and LLVM is under no obligation to exploit it when compiling in release mode.

I'm not sure what this should be changed to, which is why I'm not just submitting a PR.

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels May 14, 2019
Centril added a commit to Centril/rust that referenced this issue May 27, 2019
Centril added a commit to Centril/rust that referenced this issue May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants