Bug 14379 – bsf(0) < 0 in loop randomly evaluates to non-zero

Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-03-31T00:01:00Z
Last change time
2015-03-31T00:26:29Z
Keywords
wrong-code
Assigned to
nobody
Creator
dlang-bugzilla
See also
https://issues.dlang.org/show_bug.cgi?id=14380

Comments

Comment #0 by dlang-bugzilla — 2015-03-31T00:01:55Z
////////// 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.
Comment #1 by dlang-bugzilla — 2015-03-31T00:21:53Z
I just saw this in the documentation: "The return value is undefined if v is zero." So I guess this makes this bug report invalid. However, I think it would be appropriate if non-release builds had an assert check.