-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
The type loader has silent integer overflows #97412
Comments
/cc @steveisok |
Is this really an integer overflow in the type loader? Spec for the IL sizeof instruction says the result is unsigned int32. The code generated by Roslyn treats it like it was signed so it gets formatted as signed but it wasn't. The signedness of the value disappears on the IL evaluation stack so it's not bad IL, but still kind of wrong. Cc @jaredpar |
The spec for C# says it's a signed int. 🤷 That decision was so long ago, hard to say why the two disagreed here. Wonder if that was due to CLS compliance and wanting to avoid unsigned types in the language. That's just speculation. But either way, it's very explicit in the language that it's done this way. |
I agree that the runtime is following the IL spec and the problem is technically in C#. I think we should make the runtime fit C# that is our primary user experience. |
From: #95193 (comment)
These silent integer overflows are present in handling of LayoutKind.Sequential as well. For example, this:
prints -2147483648.
The text was updated successfully, but these errors were encountered: