On Thursday, 19 May 2016 at 23:21:14 UTC, Jonathan M Davis wrote:
No. D's const and immutable provide no backdoors. Rather, they provide strong guarantees. So, if a variable is const, then it cannot be mutated (even internally) except via a mutable reference to the same data.
The "even internally" is incorrect, and I think needs fixing: currently you can synchronize on an immutable/const object, but the synchronize implementation will write to __monitor inside the object (the field after vptr) and gone is the guarantee. This means that you cannot put immutable objects in readonly data, for example. We had to make TypeInfo objects mutable in LDC exactly because of optimization errors due to this const guarantee breakage.
I still have to write up a detailed bug report about it... - Johan