Skip to content

Check discriminant during const eval #73146

Closed
@Aaron1011

Description

@Aaron1011

In #73137 (comment), an invalid Downcast is being generated for the generator state enum (the wrong variant is used). The MIR interpreter code doesn't actually verify that the expected and actual discriminants match when performing a Downcast. While doing this would not have caught the previous issue, it would allow us to detect U.B. at the point where it actually occurs, rather than needing to wait for invalid data to be read due to the wrong downcast.

This would require us to do several operations where we currently just change the layout of an MPlaceTy, so it might make sense to only run this check in Miri (not normal const-eval).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-miriArea: The miri toolC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions