November 04, 2020 [Issue 21363] New: [REG2.094] Implementation of core.bitop.ror(x,0) is using UB | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: johanengelen@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. -- |
Copyright © 1999-2021 by the D Language Foundation