www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19402] New: bitshift with long shift amount results in int


          Issue ID: 19402
           Summary: bitshift with long shift amount results in int instead
                    of long
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dkorpel live.nl

"If the operands are of integral types, they undergo the Usual Arithmetic
Conversions, and then are brought to a common type using the Usual Arithmetic

"If both are signed or both are unsigned, the smaller type is converted to the

long x = 1L;
auto a = 1 << x;
Compiles to: (-vcg-ast)
long x = 1L;
int a = 1 << cast(int)x;

I expected this:
long x = 1L;
long a = 1L << x;

Which caused a nasty bug in my program.

Nov 15 2018