On Sunday, 14 June 2026 at 09:06:13 UTC, Kagamin wrote:
```
char BitsToChar(in uint bit5)
{
        const uint b=bit5&0x1f;
        return b<10?'0'+b:'a'+(b-10);
}
```
This code can't implicitly convert to char, but a version without parentheses `'a'+b-10` can. Is this intended or I miss something?

I believe VRP is correctly recognising here `b` can't be more than 31, but is missing that the subexpression won't be evaluated if it's less than 10.

If I'm right, it's a limitation of value range propagation - Had I to choose, I'd say it's not exactly a bug, but I leave it to others to judge that.
  • vrp bug? Kagamin via Digitalmars-d-learn
    • Re: vrp bug? Forum User via Digitalmars-d-learn
    • Re: vrp bug? Dukc via Digitalmars-d-learn

Reply via email to