-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
Add a test for #107975 #127003
base: master
Are you sure you want to change the base?
Add a test for #107975 #127003
Conversation
#![feature(exposed_provenance)] | ||
|
||
use std::ptr::addr_of; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd better add a comment describing the expected result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
assert_ne!(i, 0); | ||
println!("{}", i); | ||
assert_eq!(i, 0); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add some more scenarios like #107975 (comment), #107975 (comment), #107975 (comment) and #107975 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@rustbot author |
This comment has been minimized.
This comment has been minimized.
@rustbot ready |
The int is zero. But also not zero. This is so much fun.
This is a part of #105107.
Initially I was going to just rebase #108445, but quite a few things changed since then:
a ?= b
for Miscompilation: Equal pointers comparing as unequal #107975 anymore. Now you have toa-b ?= 0
. This is what this PR does. As an additional flex, it show that three ways of converting a pointer to its address have this issue:as usize
.expose_provenance()
.addr()
As an aside, the naming for
addr_of!
is quite unfortunate in context of provenance APIs. Becauseaddr_of!
gives you a pointer, but what provenance APIs refer to as "address" is theusize
value. Oh well.UPD1: GitHub is incapable of parsing #107975 in the PR name, so let's add it here.
Footnotes
UPD2: The other mcve does not work anymore either, saying "this behavior recently changed as a result of a bug fix; see tracking issue for "universe transition" #56105 for details." ↩