[OT] The Usual Arithmetic Confusions
Steven Schveighoffer
schveiguy at gmail.com
Thu Feb 3 13:22:42 UTC 2022
On 2/3/22 12:50 AM, Walter Bright wrote:
> On 2/2/2022 6:25 PM, Siarhei Siamashka wrote:
>> On Thursday, 3 February 2022 at 01:05:15 UTC, Walter Bright wrote:
>>> On 2/2/2022 3:37 PM, Adam Ruppe wrote:
>>>> The value range propagation only works inside single expressions and
>>>> is too conservative to help much in real code.
>>>
>>> I find it works well. For example,
>>>
>>> int i;
>>> byte b = i & 0xFF;
>>>
>>> passes without complaint with VRP.
>>
>> No, it's doesn't pass: `Error: cannot implicitly convert expression i
>> & 255 of type int to byte`.
>
> My mistake. b should have been declared as ubyte.
Which is interesting, because this is allowed:
```d
int i;
ubyte _tmp = i & 0xFF;
byte b = _tmp;
```
-Steve
More information about the Digitalmars-d
mailing list