Skip to content

Documentation for unreachable macro incorrectly describes unreachable_unchecked #60754

Closed
@nuew

Description

@nuew

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions