'int' is enough for 'length' to migrate code from x86 to x64

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 21 00:43:08 PST 2014


On 11/21/2014 12:10 AM, Daniel Murphy wrote:
> "Walter Bright"  wrote in message news:m4mggi$e1h$1 at digitalmars.com...
>
>> BTW, granted the 0x7FFFFFFF problems exhibit the bugs less often, but
>> paradoxically this can make the bug worse, because then it only gets found
>> much, much later in supposedly tested & robust code.
>>
>> 0 crossing bugs tend to show up much sooner, and often immediately.
>
> I don't think I have ever written a D program where an array had more than 2^^31
> elements.  And I'm sure I've never had it where 2^31-1 wasn't enough and yet
> 2^^32-1 was.

There turned out to be such a bug in one of the examples in "Programming Pearls" 
that remained undetected for many years:

http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html


> Zero, on the other hand, is usually quite near the typical array lengths and
> differences in lengths.

That's true, that's why they are detected sooner, when it is less costly to fix 
them.


More information about the Digitalmars-d mailing list