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

Ary Borenszweig via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 21 09:39:41 PST 2014


On 11/21/14, 1:32 PM, Andrei Alexandrescu wrote:
> On 11/21/14 6:17 AM, Ary Borenszweig wrote:
>> On 11/21/14, 5:45 AM, Walter Bright wrote:
>>> On 11/21/2014 12:10 AM, bearophile wrote:
>>>> Walter Bright:
>>>>
>>>>> All you're doing is trading 0 crossing for 0x7FFFFFFF crossing
>>>>> issues, and
>>>>> pretending the problems have gone away.
>>>>
>>>> I'm not pretending anything. I am asking in practical programming what
>>>> of the
>>>> two solutions leads to leas problems/bugs. So far I've seen the
>>>> unsigned
>>>> solution and I've seen it's highly bug-prone.
>>>
>>> I'm suggesting that having a bug and detecting the bug are two different
>>> things. The 0-crossing bug is easier to detect, but that doesn't mean
>>> that shifting the problem to 0x7FFFFFFF crossing bugs is making the bug
>>> count less.
>>>
>>>
>>>>> 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.
>>>>
>>>> Is this true? Do you have some examples of buggy code?
>>>
>>> http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html
>>>
>>>
>>>
>>
>> "This bug can manifest itself for arrays whose length (in elements) is
>> 2^30 or greater (roughly a billion elements)"
>>
>> How often does that happen in practice?
>
> Every time you read a DVD image :o). I should say that in my doctoral
> work it was often the case I'd have very large arrays.

Oh, sorry, I totally forgot that when you open a DVD with VLC it reads 
the whole thing to memory.

</sarcasm>


More information about the Digitalmars-d mailing list