length's type.
Kagamin
spam at here.lot
Fri Feb 16 10:19:30 UTC 2024
On Tuesday, 13 February 2024 at 23:57:12 UTC, Ivan Kazmenko wrote:
> I do use lengths in arithmetic sometimes, and that leads to
> silent bugs currently. On the other hand, since going from 16
> bits to 32 and then 64, in my user-side programs, I had a flat
> zero bugs because some length was 2^{31} or greater -- but at
> the same time not 2^{32} or greater. So, in D, I usually
> `to!int` or `to!long` them anyway. Or cast in
> performance-critical places.
I had a similar bug in C++: the find function returns npos
sentinel value when not found, it was assigned to uint and then
didn't match npos on comparison, but it would if they were signed.
More information about the Digitalmars-d-learn
mailing list