Thread overview
[Issue 23743] wrong code with `foreach`, `ubyte`, `>=`, ternary operator
Feb 26, 2023
ponce
Feb 26, 2023
Dennis
Feb 26, 2023
Dennis
Feb 26, 2023
Dlang Bot
Feb 27, 2023
Iain Buclaw
Feb 27, 2023
Ketmar Dark
Mar 01, 2023
Dlang Bot
Mar 01, 2023
Dlang Bot
February 26, 2023
https://issues.dlang.org/show_bug.cgi?id=23743

ponce <aliloko@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |backend
                 CC|                            |aliloko@gmail.com

--
February 26, 2023
https://issues.dlang.org/show_bug.cgi?id=23743

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dkorpel@live.nl

--- Comment #1 from Dennis <dkorpel@live.nl> ---
Reduced to avoid `foreach` lowering:

```
void main()
{
    ubyte[] a = [1u];
    ulong i = 0;
    for (;;)
    {
        ubyte x = a[i];
        ubyte v = x >= 1 ? 255 : 0;
        assert(cast(int)v == 255);
    }
}
```

--
February 26, 2023
https://issues.dlang.org/show_bug.cgi?id=23743

--- Comment #2 from Dennis <dkorpel@live.nl> ---
Related: issue 11565 and issue 12164

It looks like it generates `NEG DH` to set the `v` to 255, but it should be setting the RSI register.

--
February 26, 2023
https://issues.dlang.org/show_bug.cgi?id=23743

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@dkorpel created dlang/dmd pull request #14919 "Fix 23743 - wrong code with `foreach`, `ubyte`, `>=`, ternary operator" fixing this issue:

- Fix 23743 - wrong code with `foreach`, `ubyte`, `>=`, ternary operator

https://github.com/dlang/dmd/pull/14919

--
February 27, 2023
https://issues.dlang.org/show_bug.cgi?id=23743

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
February 27, 2023
https://issues.dlang.org/show_bug.cgi?id=23743

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ketmar@ketmar.no-ip.org

--
March 01, 2023
https://issues.dlang.org/show_bug.cgi?id=23743

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #14919 "Fix 23743 - wrong code with `foreach`, `ubyte`, `>=`, ternary operator" was merged into stable:

- 40c3200a2017ad55669c797d09f1358a82ace75c by Dennis Korpel:
  Fix 23743 - wrong code with `foreach`, `ubyte`, `>=`, ternary operator

https://github.com/dlang/dmd/pull/14919

--
March 01, 2023
https://issues.dlang.org/show_bug.cgi?id=23743

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #14938 "merge stable" was merged into master:

- f8cfdcd7ca96eb445cfda1b752904b34347aa1f4 by Dennis Korpel:
  Fix 23743 - wrong code with `foreach`, `ubyte`, `>=`, ternary operator

https://github.com/dlang/dmd/pull/14938

--