Implicit conversion error
Paul via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri May 1 00:37:08 PDT 2015
On Thursday, 30 April 2015 at 22:24:15 UTC, bearophile wrote:
> Paul:
>
>> When compiled on a 64 bit machine, this line
>>
>> int r = uniform(0, mobs.length);
>
> ".length" returns a size_t, and 0 is an int. uniform() probably
> decides to unify those types to a size_t. A size_t is 32 bit on
> 32 bit machines and 64 bits on 64 bit machines. But D "int" is
> always a 32 bit signed integer. D allows implicit assignment of
> a 32 bit size_t to int but not a 64 bit size_t to an int. I
> agree that it's a bit of a mess.
>
> Bye,
> bearophile
Thank you for the explanation, it makes perfect sense despite
being a bit of a surprise. (I should have worked this out for
myself but I haven't figured out how to use the documentation
properly yet!).
Paul
More information about the Digitalmars-d-learn
mailing list