Skip to content
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

Closed
grahame opened this issue Apr 8, 2012 · 5 comments · Fixed by #2205
Closed

float::from_str and NaN/inf/-inf #2165

grahame opened this issue Apr 8, 2012 · 5 comments · Fixed by #2205
Assignees
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.
Milestone

Comments

@grahame
Copy link
Contributor

grahame commented Apr 8, 2012

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.

@boggle
Copy link
Contributor

boggle commented Apr 8, 2012

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.

@brson
Copy link
Contributor

brson commented Apr 9, 2012

If this is standard behavior for converting from strings than I say go for it.

@boggle
Copy link
Contributor

boggle commented Apr 9, 2012

More things to check

  • proper handling of +0.0 vs -0.0 vs 0.0
  • hexadecimal notation for the mantissa for the lossless exchange of values

@boggle
Copy link
Contributor

boggle commented Apr 10, 2012

The last one is discusses in #1433. The real kicker would be if all this were supposed by the parser as literal syntax.

@brson
Copy link
Contributor

brson commented Apr 14, 2012

Fixed by 6b5731e

@brson brson closed this as completed Apr 14, 2012
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2022
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.
celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants