-
Notifications
You must be signed in to change notification settings - Fork 16
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
Comparison with Instant of u32::MAX is unsound #35
Comments
Hi, this looks correct to me. I think the documentation needs clarification here |
And thanks for bringing this to my attention! |
Interesting, thanks for the explanation! What do you think about adding an Instant::MAX constant? :) |
I see what you want, but it would be difficult. Does that make sense? |
Hmm, I think so. If we would define Instant::MAX + Instant::from_ticks(1) > Instant::MAX |
That is correct. |
You can run this test to verify: #[test]
fn yolo() {
let max = Instant::<u32, 1, 1>::from_ticks(core::u32::MAX / 2 - 1);
let maxpone = Instant::<u32, 1, 1>::from_ticks(core::u32::MAX / 2);
assert!(maxpone > max);
} |
I try this code on a thumbv7em-none-eabihf target:
Output:
Since
u32::MAX > 1000
, something seems to be wrong inside ofconst_cmp
?The text was updated successfully, but these errors were encountered: