Repository navigation
Conversation
Reading an out-of-range discriminant for an enum whose layout is an aggregate (not a scalar or scalar pair) was reported as valid. The validity requirement was derived only from the type's top-level scalar, which an aggregate layout lacks, so the discriminant tag went unchecked. Build the tag's range check directly from the tag scalar in the VariantsShape::Multiple arm, at the tag's offset. Scalar and scalar-pair enums already get this from their top-level scalar, so skip them there. Resolves model-checking#5023
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #5023.
-Z valid-value-checksdid not report an invalid discriminant when an enum's layout is an aggregate rather than a scalar or scalar pair.The fix reads the tag scalar's valid range in the
VariantsShape::Multiplearm and checks it at the tag's offset. Aggregate-layout enums now get the same validity treatment as scalar and scalar-pair enums, including the mutable-cast restriction.Testing
tests/expected/valid-value-checks/aggregate_enum.rs: a raw-pointer read with an out-of-range tag failsInvalid value of type `G`, a tag one past the valid range fails too, and valid tags verify.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.