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

Ali Çehreli acehreli at yahoo.com
Fri Apr 1 20:56:19 UTC 2022


On 4/1/22 13:47, Steven Schveighoffer wrote:

 >> I think this rule is related to C's accepting wildly different
 >> platforms, some of which may have different kinds of memory. Two
 >> pointers to different kinds of memory may not be subtracted.
 >
 > Well, can the pointers be subtracted? Yes.

My understanding is that depending on the CPU, certain operations would 
make the CPU barf. I am not sure but the old protected memory, extended 
memory, etc. systems might not be able to subtract between the systems 
at all. (Not sure; I am making this up.)

 > This is why I don't know that it's important to avoid it.

I will not avoid it. :)

Ali



More information about the Digitalmars-d mailing list