-
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
float::from_str and NaN/inf/-inf #2165
Comments
It will be very good when this will be fixed. There are some additional points to be considered: If I remember correctly, the floating point standard allows for both short ("inf") and long ("infinity") syntax. Are you aware of the other float formatting related issues? I think there used to be a floating point literal parsing problem in rustc for very large literals (not fitting into 32 bits) that is related (can't find the issue right now). Besides adding support for NaN and inf in from_str/to_str, I personally think rust should define a literal syntax for these, i.e. the compiler should support them directly. |
If this is standard behavior for converting from strings than I say go for it. |
More things to check
|
The last one is discusses in #1433. The real kicker would be if all this were supposed by the parser as literal syntax. |
Fixed by 6b5731e |
Add support for _COARSE clocks Original idea does not work, so I'm just going to try expanding support to include the `_COARSE` clocks. The original motivation for this PR is that the test suite for the crate [`minstant`](https://crates.io/crates/minstant) reports UB, because it tries to use a clock type Miri didn't support, but never checked for an error code and so just used the uninit `libc::timespec`. So, that's technically a bug in `minstant`, but outside of Miri you'd have to be using an incredibly old Linux to ever see an `EINVAL` so the more helpful thing for Miri to do is behave like a newer Linux. So now we don't detect UB in `minstant`, but we have a test failure: ``` failures: ---- src/instant.rs - instant::Instant::as_unix_nanos (line 150) stdout ---- Test executable failed (exit status: 101). stderr: thread 'main' panicked at 'assertion failed: (instant.as_unix_nanos(&anchor) as i64 - expected as i64).abs() < 1_000_000', src/instant.rs:11:1 ``` I'm having trouble getting my head around the code in `minstant` that's involved in this test, but as far as I can tell from the man pages, these `_COARSE` clocks meet the requirements. Closes rust-lang/miri#1983 at least as best as I can.
We now store Kani's version and the failure reason (if there's one) into the assess metadata. For now, we still need to manually parse this information, but this moves us closer to rust-lang#2058 and rust-lang#2165. In order to collect more details about the compilation errors, we now inspect the cargo diagnostic messages.
Should float::from_str do the following conversions?
"NaN" -> float::NaN
"inf" -> float::infinity
"-inf" -> float::neg_infinity
That'd match what float::to_str does (if my pull request #2164 is merged.)
If this sounds good I'll chuck a patch in.
The text was updated successfully, but these errors were encountered: