Skip to content

Add a macro for "unreachable" whose meaning differs in debug and release builds  #18152

@kmcallister

Description

@kmcallister

In debug builds it means "I think we can't get here, please fail!() if we do", i.e. the same as the current unreachable!().

In release builds it means "I promise we can't get here, LLVM, you are free to do absolutely anything if we can", i.e. intrinsics::unreachable().

Improper use can totally break memory safety in release builds, so we should make it unsafe-only even in debug builds. For the same reason I don't think the current unreachable!() should change meaning to this. I don't have a great alternative name, which I think is the main obstacle with this ticket!

E-easy E-bikeshed :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)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