[Issue 22988] Error: shift by -1 is outside the range `0..31`
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Apr 5 08:15:53 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22988
Max Samukha <maxsamukha at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |---
--- Comment #2 from Max Samukha <maxsamukha at gmail.com> ---
The precedence is intended to be (a ? (1 << (a - 1)) : 0).
Since 'a' is 0, the first branch of the conditional shouldn't be evaluated, and
the expected result is 0.
Compare that to the runtime version, which behaves as expected:
void main()
{
int a = 0;
int b = a ? 1 << a - 1 : 0;
assert(b == 0);
}
--
More information about the Digitalmars-d-bugs
mailing list