Weird issue with std.range.iota.length

tsbockman via Digitalmars-d digitalmars-d at puremagic.com
Fri Feb 12 02:34:32 PST 2016


On Friday, 12 February 2016 at 08:11:57 UTC, Jonathan M Davis 
wrote:
> Regardless of which way we go, the problem will _eventually_ go 
> away when 32-bit systems finally die out, but that's likely to 
> take a while.

Many micro-controllers will probably remain 32-bit indefinitely; 
64-bit is just a waste of power for most applications. Even if 
you want to ignore non-PC/smartphone CPUs, we'll still have the 
same problem whenever someone gets around to implementing 128-bit 
cent/ucent.

Ultimately, the only real solution to this kind of problem is 
some combination of:

1) Select the right type for the job (don't use `ulong` when you 
really mean `size_t`), and

2) Bounds checking. If iota's length is not expressible as a 
`size_t`, convert it to one *safely* using `std.conv.to()`.

Anything less is just asking for bugs.


More information about the Digitalmars-d mailing list