On Wednesday, 8 May 2024 at 14:26:25 UTC, Paul Backus wrote:
When the following program is compiled with GDC 14.1, the assertion fails:

    void main() {
        int d = 42;
        bool o = d > d++;
        assert(o == false);
    }

(Godbolt: https://d.godbolt.org/z/e63xbb9Td)

The assertion passes when the program is compiled with DMD 2.108.0.

The same bug was recently reported for LDC: https://github.com/ldc-developers/ldc/issues/4651

I want to say that rewriting `d > d++` to `d++ < d` is a valid optimization.

See also `opCmp` rewriting `a < b` into `b.opCmp(a)`

https://dlang.org/spec/operatoroverloading.html#compare

Reply via email to