Bug 21363 – [REG2.094] Implementation of core.bitop.ror(x,0) is using UB
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-11-04T00:33:01Z
Last change time
2021-05-12T16:37:33Z
Keywords
industry, pull
Assigned to
No Owner
Creator
johanengelen
Comments
Comment #0 by johanengelen — 2020-11-04T00:33:01Z
This is a long-standing bug (in practice it doesn't result in UB), and now comes out due to better CTFE checking of UB.
Testcase:
```
import core.bitop;
enum a = ror(uint(1), 0); // rotate by 0, should be allowed.
```
The test case no longer compiles with 2.094.0:
core/bitop.d(961): Error: shift by 32 is outside the range 0..31
rortest.d(1): called from here: ror(1u, 0u)
The problem is that the implementation of `ror` is indeed shifting by a too large amount.
Note that `rol` has the same problem.