www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13383] New: wrong code with -O with ints, longs and bitwise


          Issue ID: 13383
           Summary: wrong code with -O with ints, longs and bitwise
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: gassa mail.ru

Consider the following code (minimized example):
void main () {
    foreach (k; 32..33) {
        if (1L & (1L << k)) {
            assert (false);

Obviously, 1L & (1L << k) must be true only when k = 0.

Still, with k = 32, it produces a true value when compiled with "dmd -O".

All is well without "-O".

It is reproducible for me with DMD 2.064.2-2.066.0 on Win32.  It works for me
with DMD 2.063.2.  So, the issue was probably introduced between 2.063.2 and

Aug 27 2014