-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
i32::pow only handles overflow up to an exponent of 1023 #28012
Comments
/cc @rust-lang/libs @rust-lang/lang is this intended behavior? |
I'm not sure this is intended behavior, and if it was, it does seem a little surprising. What seems to happen is if the exponent is even, and each iteration of the |
This looks like a bug, seems fine to fix |
I agree with @alexcrichton |
Overflows in integer pow() computations would be missed if they preceded a 0 bit of the exponent being processed. This made calls such as 2i32.pow(1024) not trigger an overflow.
This would catch regressions of issue rust-lang#28012.
Overflows in integer pow() computations would be missed if they preceded a 0 bit of the exponent being processed. This made calls such as 2i32.pow(1024) not trigger an overflow. Fixes #28012
Playpen: http://is.gd/zhwksu
Prints:
Interestingly, this only seems to happen with an even base. The overflow is detected correctly when
x
is set to 3 or other odd numbers.The text was updated successfully, but these errors were encountered: