www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14379] New: bsf(0) < 0 in loop randomly evaluates to non-zero

https://issues.dlang.org/show_bug.cgi?id=14379

          Issue ID: 14379
           Summary: bsf(0) < 0 in loop randomly evaluates to non-zero
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: thecybershadow gmail.com
                CC: briancschott gmail.com

////////// test.d /////////
import core.bitop : bsf;

void main()
{
    foreach (_; 0 .. 1)
    {
        int j = bsf(0) < 0;
        assert(j == 0);
    }
}
///////////////////////////

On Ubuntu Linux 14.10, when compiled with DMD 2.067.0 (`dmd -m64 test.d`), the
assert in the above program will fail 50% of the time the program is ran.

Reduced from Issue 14323.

--
Mar 30 2015