Pitch: Implicit Pointer Conversion for C Interoperability

If I may try my hand at an explanation, would something like the following be in line with what binding memory does?

“The act of binding a pointer to a data type constitutes a promise from the programmer to the compiler, that the memory referenced by that pointer will not be accessed as another type, either directly or through a differently-typed pointer, for as long as that pointer remains bound to that type.

The compiler is then free to reorder accesses through that pointer relative to any differently-typed accesses, and perform related optimizations, without needing to reload memory from the pointer, because it has been promised that differently-typed operations will not affect the memory referenced by that pointer, and vice versa.

If the programmer breaks the promise and accesses the same memory as a different type, then the contents of that memory end up in an undefined state, because there is no guarantee about which accesses will be performed in which order. This can result in malformed instances, corrupted data, broken invariants, unintended application state, and arbitrary security breaches.”

…am I close?

12 Likes