dmd 1.046 and 2.031 releases
Don
nospam at nospam.com
Fri Jul 17 05:08:23 PDT 2009
BCS wrote:
> Reply to bearophile,
>
>> John C:
>>
>>> Did you not read the change log?
>>> "Implicit integral conversions that could result in loss of
>>> significant bits are no longer allowed."
>> This was the code:
>> ubyte m = (n <= 0 ? 0 : (n >= 255 ? 255 : n));
>> That last n is guaranteed to fit inside an ubyte (yes, I understand
>> the compiler is not smart enough yet to understand it, but from the
>> things explained by Andrei I have thought it was. So I am wrong and I
>> have shown this to other people, that may be interested. I have also
>> encouraged to make the compiler smarter to avoid a cast in such case,
>> because this is a single expression, so range propagation is probably
>> not too much hard to implement given the current design of the
>> front-end. You have missed most of the purposes of my post).
>>
>> Bye,
>> bearophile
>
> I'm going with Steven on this one. Making the legality of code dependent
> on it's semantics is risky because it then ends up with bazaar
> portability issues or requiters that the scope of the semantics analysts
> engine be part of the language spec.
>
>
In this case, I think bearophile's right: it's just a problem with range
propagation of the ?: operator. I think the compiler should be required
to do the semantics analysis for single expressions. Not more, not less.
More information about the Digitalmars-d-announce
mailing list