D has the same memory model as C++

Bastiaan Veelo Bastiaan at Veelo.net
Tue Aug 10 21:25:08 UTC 2021


On Tuesday, 10 August 2021 at 18:13:17 UTC, Tejas wrote:
> On Tuesday, 10 August 2021 at 18:07:35 UTC, Bastiaan Veelo 
> wrote:
>> On Tuesday, 10 August 2021 at 16:00:37 UTC, Tejas wrote:
>>> there's casting away const, a clearly seperate language 
>>> feature which has no equivalent in D;
>>
>> You *can* cast away `const` in D: 
>> https://run.dlang.io/is/sWa5Mf
>>
>> — Bastiaan.
>
> Yes, but it is UB, not defined and supported by the 
> standard/implementation.

OK, strictly speaking casting away `const` is in the language, 
but modifying after that is UB.
https://dlang.org/spec/const3.html#removing_with_cast

— Bastiaan.


More information about the Digitalmars-d-learn mailing list