-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Casting negative double to uint does not seem to meet the specification, and works inconsistently across platforms #45429
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
I forgot that default context is unchecked so it's fine, need more sleep. |
If it's |
According to the C# spec the unchecked case goes as following:
I'm wondering how do we handle the "unspecified value" cases. Is it our equivalent of C++ UB? |
If I'm not missing anything, the following code should throw
System.OverflowException
according to the Explicit numeric conversions section of the C# language specification:Instead, it will print
uint.MaxValue
on x86.On Arm64, it seems to return
0
based on my understanding of #45249. I don't have a local repro, but the problem seems to be with the following code on CI:runtime/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs
Lines 1010 to 1011 in 301056d
When we are casting
Timeout.InfiniteTimeSpan.TotalMilliseconds == -1.0
touint
the conversion seems to result in0
on Arm64, while (also incorreclty) returning -1 on x86.The text was updated successfully, but these errors were encountered: