-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Check generic construction diagnostics for stackalloc to span conversions #25131
Conversation
cc @dotnet/roslyn-compiler for review |
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.
cc @AlekseyTs as you first raised this in a different PR. |
@OmarTawfik May we sync |
@alrz. Yes. The owner of the feature branch can update it from 15.7.x once approved and merged. |
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.
LGTM. Please get compat council to OK the break before merging.
Yes. We should check with compat council. It is highly unlikely though that this breaks any functional code. Allowing Span in stackalloc would easily result in a GC holes and heap corruption. |
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.
LGTM
@jaredpar for ask mode approval. |
@jaredpar can you please take a look? |
approved |
Closes #25086
Closes #25038
There is a bug in C# 15.5, where during the conversion of a
stackalloc
expression to aSpan<T>
object creation, the type parameter construction and constraints matching were not checked during binding.Fixing this for 15.7 is a breaking change, because an expression of
stackalloc T [count]
would be legal even ifT
was not legal to initializeSpan<T>
with. We would previously emit IL even if it would cause run time exceptions. do believe that the scope is small enough for us to take the breaking change though.