Reducing Raw Pointer Footguns: Preventing Reference Aliasing Violations at Compile Time
fuji-184:
That code avoids the point because it avoids mixing raw pointers and references
I simply replaced your AliasableGuardMut with a mutable reference and made no changes to avoid mixing raw pointers and references. This means that your code didn't really need the capabilities of raw pointers in the first place and is thus not a valid example of where AliasableGuardMut would help.
fuji-184:
So the body of the example is not important by itself. The important part is: “assume this operation requires a raw pointer”.
Assumptions are ok only as long as they don't matter for the point you're making. They matter in your examples though.
fuji-184:
The example gives compile time error. Did you run with the code in the opening post?
The examples themselves were incomplete so I didn't run them.
fuji-184:
Where 1 one the example is indeed invalidate the head. That is because I didn't wrap the head pointer with the guard. After I wrap all will guard, it now prevents the head pointer invalidation
No, the head is still invalidated because you use the node mutable reference after creating the head. It's another example where your AliasableGuardMut does not prevent this kind of issues.
Discussion in the ATmosphere