PS[test]$ type oneiszero.d void main() { byte[1] a = [1]; int b = 0; // If delete this 4 lines, the result is correct. if (a[b] == 0) { a[b] = 0; if (1 << b) { } } // If enable this assertion, the result is correct. // assert ((a[b] & 0xFF) == 1); if ((a[b] & 0xFF) == 0) { // Oddly, this block is executed. dmd 2.085.0(-m64) with Windows 8.1 or 10. assert((a[b] & 0xFF) == 0); } } PS[test]$ dmd.exe -m64 -run oneiszero.d core.exception.AssertError@oneiszero.d(16): Assertion failure ---------------- 0x00007FF6803611DB 0x00007FF68036110E 0x00007FF6803619F2 0x00007FF68036187F 0x00007FF68036195B 0x00007FF68036187F 0x00007FF6803617B1 0x00007FF680361134 0x00007FF68038B618 0x00007FFC809713D2 in BaseThreadInitThunk 0x00007FFC80CC54F4 in RtlUserThreadStart PS[test]$
Introduced by https://github.com/dlang/dmd/pull/9015 but the root cause is probably elsewhere.
@rainers created dlang/dmd pull request #10047 "fix Issue 19758 - (0x01 & 0xFF) == 0 by dmd 2.085.0(-m64) on Window" fixing this issue: - fix Issue 19758 - (0x01 & 0xFF) == 0 by dmd 2.085.0(-m64) on Window operation "test SIL,SIL" needs REX prefix https://github.com/dlang/dmd/pull/10047
dlang/dmd pull request #10047 "fix Issue 19758 - (0x01 & 0xFF) == 0 by dmd 2.085.0(-m64) on Window" was merged into stable: - 01b7ee6f0906b0fbc3a78b024b0a749d1b56d249 by Rainer Schuetze: fix Issue 19758 - (0x01 & 0xFF) == 0 by dmd 2.085.0(-m64) on Window operation "test SIL,SIL" needs REX prefix https://github.com/dlang/dmd/pull/10047