On 12/15/2013 3:52 AM, Timon Gehr wrote:
On 12/15/2013 02:20 AM, Walter Bright wrote:
On 12/14/2013 4:36 PM, Timon Gehr wrote:
I cannot cast data from my own storage allocator to immutable because the
behaviour will be undefined.

http://dlang.org/const3.html

Is this a documentation bug? What should be the actual rules?

It means it's up to you to ensure it is correct.

Undefined behaviour is a term with a precise meaning. That site says that
casting a reference to immutable while there are still live mutable references
to memory reachable by that reference leads to undefined behaviour. It is not
possible to 'ensure it is correct'.

You, as the guy who wrote the code, will (or should) know that there are no other live references, hence you are telling the compiler "trust me, I know there aren't any".

Reply via email to