[Issue 22163] New: wrong code with static float array and delegate accessing it

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 1 14:51:43 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=22163

          Issue ID: 22163
           Summary: wrong code with static float array and delegate
                    accessing it
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: backend, wrong-code
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dkorpel at live.nl

Reduced code:
```
import core.stdc.stdio;

void drawText(float[2] size) {
    printf("%f %f\n", size[0], size[1]);
    scope dg = (int x) => size[0];
}

extern(C) void main() {
    float[2] size = [10.0, 20.0];
    printf("%f %f\n", size[0], size[1]);
    drawText(size);
}
```

Prints:
10.000000 20.000000
10.000000 0.000000

It should print 20 instead of 0 for `size[1]` the second time. It works with
LDC, so I assume it's a backend / glue code bug. It also works on Windows, or
when replacing `float` with `int`, or without the delegate.

--


More information about the Digitalmars-d-bugs mailing list