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

.sqrt() has a wrong behaviour for negative floats #7347

Closed
MaikKlein opened this issue Jun 24, 2013 · 7 comments
Closed

.sqrt() has a wrong behaviour for negative floats #7347

MaikKlein opened this issue Jun 24, 2013 · 7 comments

Comments

@MaikKlein
Copy link
Contributor

-0.5f.sqrt().is_NaN evaluates to false on "df166ba"

@alexcrichton
Copy link
Member

This appears to be a problem with optimizations. With optimizations disabled the correct value is printed. This may be another case which #7115 addresses

@MaikKlein
Copy link
Contributor Author

It happened on rusti in IRC. I was told that it doesn't use -O

@MaikKlein MaikKlein reopened this Jun 24, 2013
@alexcrichton
Copy link
Member

Are you sure?

$ cat foo.rs                                           
fn main() {
  print(fmt!("%?", (-0.5f).sqrt().is_NaN()));
}
$ rustc -Z jit foo.rs                                  
true
$ rustc -O -Z jit foo.rs                               
false
$ rust run foo.rs                                     
warning: no debug symbols in executable (-arch x86_64)
true
$ rustc -O foo.rs
warning: no debug symbols in executable (-arch x86_64)
$ ./foo
false

@MaikKlein
Copy link
Contributor Author

I am not sure, I am building the newest master now and then I test again. But you are probably right that it only happens on -O

@MaikKlein
Copy link
Contributor Author

Yes -O is the problem

@thestinger
Copy link
Contributor

the bot on irc uses rustc without -O (if that's helpful)

@alexcrichton
Copy link
Member

#7115 has landed, this should be fixed now.

flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 21, 2021
FIx FP in `missing_safety_doc` lint

Fix FP where lint souldn't fire if any parent has `#[doc(hidden)]` attribute

fixes: rust-lang#7347

changelog: [`missing_safety_doc`] Fix FP if any parent has `#[doc(hidden)]` attribute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants