Integer promotion... what I'm missing? (It's monday...)
Derek Parnell
derek at psych.ward
Mon Jun 19 05:38:00 PDT 2006
On Mon, 19 Jun 2006 20:11:32 +1000, Tony <ignorethis at nowhere.com> wrote:
>> If you read http://digitalmars.com/d/type.html, you will find the rules
>> for integer promotion under arithmetic operations (which I assume also
>> includes comparisons).
>>
>> Note point 5.4 under "Usual Arithmetic Conversions":
>>
>> 5.4. The signed type is converted to the unsigned type.
. . .
> I believe it is a mistake to have an operation like this occur when it is
> both mathematically incorrect and unintuitive. It feels like something
> that is destined to be a Bug Breeder.
No argument from me. This has often caused me grief. The two most often
gotchas for me is mismatched template parameters due to this stupid rule,
and that array length is a uint which means that all expressions involving
array.length get silently converted to uint before the evaluation and that
can mess up index accesses.
--
Derek Parnell
Melbourne, Australia
More information about the Digitalmars-d-learn
mailing list