Is D's pointer subtraction more permissive than C (and C++)?

Paul Backus snarwin at gmail.com
Fri Apr 1 19:58:28 UTC 2022


On Friday, 1 April 2022 at 19:43:01 UTC, Steven Schveighoffer 
wrote:
> On 4/1/22 2:44 PM, Paul Backus wrote:
>>
>> According to the C rules, (i) and (ii) are legal, since they 
>> point to the same memory block, but (iii) is illegal.
>
> (iii) is the same as (ii) because old_aPtr is the same as a.ptr 
> at that time.
>
> -Steve

You're right; my mistake. I misread it as `a.ptr - b.ptr`, since 
that's what the other two `assert`s do.


More information about the Digitalmars-d mailing list