On Friday, February 15, 2019 3:06:34 AM MST Kagamin via Digitalmars-d-learn 
wrote:
> Union is just a pretty cast, type system guarantees don't hold
> for it.

Well, technically, what's supposed to be the case is that when you cast, the
type system guarantees still hold but it's up to the programmer to make sure
that they do - just like how it's up to the programmer to ensure that
@trusted code is really @safe.

Rebindable is a pretty weird case with what it's doing, but I'm pretty sure
that it's actually violating the type system with what it does in that you
can't rely on the value of the immutable reference itself not being mutated
even though it's immutable. The type system guarantees for what the
reference refers to are maintained but not the guarantees for the actual
reference. In practice, I don't think that it's actually a problem, but in
principle, it's violating the type system, and a particularly aggressive
optimizer could make a bad assumption. However, given that a union is
involved, and as such the "cast" is built into the type, I question that any
optimizer would ever make the wrong assumption about Rebindable.

- Jonathan M Davis



Reply via email to