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

Casting can no longer produce undefined behavior (UB) #59

Closed
martin-t opened this issue Jul 29, 2020 · 3 comments · Fixed by #61
Closed

Casting can no longer produce undefined behavior (UB) #59

martin-t opened this issue Jul 29, 2020 · 3 comments · Fixed by #61

Comments

@martin-t
Copy link
Contributor

It looks like the 2 issues linked here and in some other places have been resolved and the reference has been updated too.

Should i update the docs?

@yoanlcq
Copy link
Owner

yoanlcq commented Jul 29, 2020

Updating the docs is a good idea. One thing to consider is that some users may not be using the latest 1.45.0 of Rust, so what I think I'll do right now is change the docs to say "hey, if you're using a version Rust before 1.45.0, then you may encounter UB as described: [insert current doc about UB here]".

Then I guess one day Rust 1.45.0 would be widespread enough that we could completely remove to parts of the doc about UB. I am unsure of when that day will come and how to measure it, but I guess that'll be fine.

@yoanlcq
Copy link
Owner

yoanlcq commented Jul 29, 2020

That should be fine, let me know if you have any thoughts about this.

@martin-t
Copy link
Contributor Author

I noticed the text here originally comes from the num-traits crate and opened a PR there. In the process, i noticed the second case (float to float conversion) probably never was UB and the second example might be removed. Might wanna keep an eye on that PR to keep the docs in sync.

bors bot added a commit to rust-num/num-traits that referenced this issue Aug 24, 2020
184: Update AsPrimitive Safety docs for rust 1.45 r=cuviper a=martin-t

Fixes #174

The safety section should not be removed entirely since people might be using older compilers (as was pointed out to me in a [related issue](yoanlcq/vek#59) in the vek crate).

However, [this](rust-lang/rust#15536 (comment)) and followup comments indicate that the second case (float to float) was never UB in the first place - should the second example be removed?

Co-authored-by: Martin Taibr <[email protected]>
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

Successfully merging a pull request may close this issue.

2 participants