Integer conversions too pedantic in 64-bit

Jacob Carlborg doob at me.com
Tue Feb 15 01:47:20 PST 2011


On 2011-02-15 01:08, Walter Bright wrote:
> dsimcha wrote:
>> Now that DMD has a 64-bit beta available, I'm working on getting a
>> whole bunch
>> of code to compile in 64 mode. Frankly, the compiler is way too freakin'
>> pedantic when it comes to implicit conversions (or lack thereof) of
>> array.length. 99.999% of the time it's safe to assume an array is not
>> going
>> to be over 4 billion elements long. I'd rather have a bug the 0.001%
>> of the
>> time than deal with the pedantic errors the rest of the time, because
>> I think
>> it would be less total time and effort invested. To force me to either
>> put
>> casts in my code everywhere or change my entire codebase to use wider
>> integers
>> (with ripple effects just about everywhere) strikes me as purity
>> winning out
>> over practicality.
>
> We dealt with that in updating Phobos/Druntime to 64 bits. The end
> result was worth it (and yes, there would have been undiscovered bugs
> without those pedantic checks).
>
> Most of the issues are solved if you use auto and foreach where
> possible, and size_t for the rest of the cases.

Yes, exactly, what's the reason not to use size_t. I've used size_t for 
length and index in arrays for as long as I've been using D.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list