A strange div bug on Linux x86_64, (both dmd & ldc2): long -5000 / size_t 2 = 9223372036854773308

Adam D. Ruppe destructionator at gmail.com
Thu Aug 13 19:56:36 UTC 2020


On Thursday, 13 August 2020 at 19:03:38 UTC, H. S. Teoh wrote:
> size_t is unsigned, because the address space of a 64-bit 
> machine is 2^64, but a signed value would only be able to 
> address half of that space (2^63).

The address bus on existing processors only uses like 48 bits and 
even there the lower three are reserved cuz of alignment.

But besides, even if you wanted it all, the signed negative value 
has the same bit pattern as the high bit set anyway so it isn't 
like the cpu would care, assuming it was actually mapped.

On 32 bit it makes a little more sense to say unsigned but even 
there the same bit pattern logic applies anyway.


More information about the Digitalmars-d mailing list