Unsafe evolution: require unsafe for some pointer operations#81240
Merged
jjonescz merged 18 commits intoNov 24, 2025
Conversation
333fred
reviewed
Nov 17, 2025
333fred
approved these changes
Nov 18, 2025
Member
Author
|
@jcouv for the second review, thanks |
jcouv
reviewed
Nov 21, 2025
jcouv
reviewed
Nov 21, 2025
|
|
||
| internal CSharpCompilationOptions WithEvolvedMemorySafetyRules() => WithMemorySafetyRules(EvolvedMemorySafetyRulesVersion); | ||
|
|
||
| internal bool HasEvolvedMemorySafetyRules => MemorySafetyRules >= EvolvedMemorySafetyRulesVersion; |
Member
Member
Author
There was a problem hiding this comment.
I think it's good to keep the terminology in line with the speclet (and later the standard). But it seems there is no terminology for this thing in the existing design docs, right, @333fred? So I will update "evolved" to "updated", thanks.
jcouv
reviewed
Nov 21, 2025
jcouv
reviewed
Nov 21, 2025
jcouv
reviewed
Nov 21, 2025
jcouv
reviewed
Nov 21, 2025
jcouv
reviewed
Nov 21, 2025
jcouv
reviewed
Nov 21, 2025
| // (1,1): error CS8652: The feature 'updated memory safety rules' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. | ||
| // int* x = null; | ||
| Diagnostic(ErrorCode.ERR_FeatureInPreview, "int*").WithArguments("updated memory safety rules").WithLocation(1, 1)); | ||
| } |
Member
There was a problem hiding this comment.
nit: consider including a test for fixed (no updated unsafe check). Could be in a later PR
Member
Author
There was a problem hiding this comment.
Yes, I'm planning to test fixed along with other remaining unsafe constructs in the next PR.
This was referenced Feb 27, 2026
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.
Test plan: #81207
Require unsafe for pointer indirection, member access, and element access when the new memory safety rules are enabled.
Unsafe is not required elsewhere (like for pointer types) under the new rules, but more restrictions will be added in follow up PRs, like to also require unsafe for function pointer invocation, etc.