More value range analysis?

Timon Gehr timon.gehr at gmx.ch
Fri Jan 4 12:40:13 PST 2013


On 01/04/2013 04:13 AM, bearophile wrote:
>> void main(string[] args) {
>>     ubyte x = cast(ubyte)args.length;
>>     immutable int y = x;
>>     // Here y must be in [0, 256[.
>> }
>
> Sorry, that example was meant to be:
>
>
> void main(string[] args) {
>      immutable ubyte x = cast(ubyte)args.length;
>      immutable int y = x;
>      // Here y must be in [0, 256[.
>      ubyte z = y;
> }
>
>
> Bye,
> bearophile

The first version is fine. The range computed for 'y' is [0..256[ in 
both cases.


More information about the Digitalmars-d mailing list