www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21363] New: [REG2.094] Implementation of core.bitop.ror(x,0)


          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.

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.

Nov 03 2020