Does black_box
expose it's address operands? Does it have a side effect dependant on its parameter?
#423
Labels
S-pending-team-decision
Status: There is broad agreement on the question
In a recent T-opsem UCG Backlog Bonanza meeting, we closed #311 declaring that, from an opsem perspective,
core::hint::black_box(x)
was no different fromcore::convert::identity(x)
.However, over on the Rust Community Discord, two questions came up that struck me as a reason to reopen a constrained version of that question, namely:
black_box
contains any pointer bytes, doesblack_box
expose those pointers?black_box
perform a side effect dependent on it's parameter?In my opinion, the answer to the first question should be "No", as there isn't a reason to make it do an expose. However, the second question is a litle more substantial. While this is not currently the case, IIRC there have been times in the past where
black_box(CONST)
orblack_box(inlineable_pure_function())
have been elided by the compiler. This is strictly allowed, but undesireable. I'm also unsure if there is a reason not to makeblack_box
perform a side effect (and the current implementation on rustc already expects this, by using an non-pure
asm!()
block that takesaddr_of!(x)
).@rustbot label +S-pending-team-decision
Note: I do not believe that there is necessarily any design that needs to happen arround "how" black-box either exposes/doesn't-expose and how it has a side effect, so this should only need a T-opsem decision as to each of the individual questions. If this assesment is wrong, feel free to relabel as S-pending-design. This also doesn't have a currently existing, suitable A- label, but as I expect this to be a one-off issue (:ferrisClueless:), I do not believe there is a need to create one.
The text was updated successfully, but these errors were encountered: