Open Fri3dNstuff opened 1 month ago
It's already noted in the issue text, but important to note that coercion of pointers-to-const *const *align(2) T
-> *const *align(1) T
can be allowed.
We only need to prevent it when the target pointer-to-mutable broadens the set of valid pointee values.
Zig Version
0.14.0-dev.367+a57479afc
Steps to Reproduce and Observed Behavior
Attempt to compile the following code:
The code compiles without errors.
Expected Behavior
The code should have triggered a compilation error.
A mutable pointer to (one / many / slice / C) a type
T
can coerce into a mutable pointer of typeU
without soundness problems if-and-only-if:T
andU
are in-memory coercible, andThese are, I believe, the most liberal coercion rules that do not result in soundness problems - I will leave the discussion about whether Zig should be this liberal with its coercion rules to another issue.