-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
ICE when casting float to integer (out-of-bounds) #45134
Comments
Looks like #10184 (which is approaching its fourth birthday) |
Same underlying issue, but a different code path than the one that's been exclusively (as far as I can tell) discussed over there. So this report was very valuable for my in-progress patch addressing #10184, thank you @samnardoni! |
jdm
added
the
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
label
Oct 10, 2017
@rkruppe No problem at all. I'm glad it's useful. |
bors
added a commit
that referenced
this issue
Nov 8, 2017
Saturating casts between integers and floats Introduces a new flag, `-Z saturating-float-casts`, which makes code generation for int->float and float->int casts safe (`undef`-free), implementing [the saturating semantics laid out by](#10184 (comment)) @jorendorff for float->int casts and overflowing to infinity for `u128::MAX` -> `f32`. Constant evaluation in trans was changed to behave like HIR const eval already did, i.e., saturate for u128->f32 and report an error for problematic float->int casts. Many thanks to @eddyb, whose APFloat port simplified many parts of this patch, and made HIR constant evaluation recognize dangerous float casts as mentioned above. Also thanks to @ActuallyaDeviloper whose branchless implementation served as inspiration for this implementation. cc #10184 #41799 fixes #45134
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following program (with perhaps undefined behaviour) causes an ICE:
Interestingly, if not wrapping the result in a
Some
, then there's no ICE.Here's the result from running it on the playground:
The text was updated successfully, but these errors were encountered: