[Issue 21363] New: [REG2.094] Implementation of core.bitop.ror(x,0) is using UB
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 4 00:33:01 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21363
Issue ID: 21363
Summary: [REG2.094] Implementation of core.bitop.ror(x,0) is
using UB
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: regression
Priority: P1
Component: druntime
Assignee: nobody at puremagic.com
Reporter: johanengelen at weka.io
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.
--
More information about the Digitalmars-d-bugs
mailing list