my new favourite wrong code bug

H. S. Teoh hsteoh at qfbox.info
Sun Feb 26 17:05:03 UTC 2023


On Sun, Feb 26, 2023 at 12:49:25PM +0000, ag0aep6g via Digitalmars-d wrote:
> ```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.

LDC and GDC both work fine.


T

-- 
Trying to define yourself is like trying to bite your own teeth. -- Alan Watts


More information about the Digitalmars-d mailing list