On 13/07/16 14:28, Andrei Alexandrescu wrote:

Interesting distinction. We must render the latter undefined but not the
former. Consider:

Here's the definition I'm proposing:
It is undefined behavior to cast away immutable, const or shared modifiers and reference the memory if any other part of the program accesses that memory with the modifiers intact.

Examples of behavior that is not undefined:
Affix allocator: Accesses memory that is always accessed as mutable
Intrusive reference counting inside a struct: same deal
Only casting a pointer: no access

Shachar

Reply via email to