Am 08.05.2014 18:10, schrieb Timon Gehr:
On 05/08/2014 06:02 PM, monarch_dodra wrote:

If you have const data referencing mutable data, then yes, you can cast
away all the const you want, but at that point, it kind of makes the
whole "const" thing moot.

This is not guaranteed to work. I guess the only related thing that is
safe to do is casting away const, but then not modifying the memory.

For what practical reason would that be the case? I know that the spec states "undefined behavior", but AFAICS, there is neither an existing, nor a theoretical reason, why this should fail:

int* i = new int;
const(int)* j = i;
int* k = cast(int*)j;
*k = 0;

Anyway this is going pretty much off topic...

Reply via email to