-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Implement compile-time boundary checks around inline arrays access. #68178
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
Implement compile-time boundary checks around inline arrays access. #68178
Conversation
|
|
||
| // PROTOTYPE(InlineArrays): Check bounds | ||
| // Check bounds | ||
| if (convertedIndex.ConstantValueOpt is { SpecialType: SpecialType.System_Int32, Int32Value: int constIndex }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this cover integer constants of other types, e.g., Int16? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this cover integer constants of other types, e.g., Int16?
We do not need to cover scenarios like that here. We can end up here only with three types: int, System.Index and System.Range. See ``tryImplicitConversionToInlineArrayIndex````, for example.
|
@cston, @dotnet/roslyn-compiler For the second review. |
| _ = f[new System.Index(0, true)]; | ||
| _ = f[new System.Index(-1, true)]; | ||
| _ = f[new System.Index(int.MinValue, true)]; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider testing: ...
Added.
No description provided.