my new favourite wrong code bug

ag0aep6g anonymous at example.com
Sun Feb 26 12:49:25 UTC 2023


```d
void main()
{
     ubyte[] a = [1];
     foreach (x; a)
     {
         ubyte v = x >= 1 ? 255 : 0;
         assert(v == 255); /* fails; should pass */
     }
}
```

Astonishing.

Filed as [issue 
23743](https://issues.dlang.org/show_bug.cgi?id=23743).

Reminds me of [issue 
18315](https://issues.dlang.org/show_bug.cgi?id=18315) ("wrong 
code for `i > 0`") which was similarly ridiculous.


More information about the Digitalmars-d mailing list