www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22163] New: wrong code with static float array and delegate


          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 puremagic.com
          Reporter: dkorpel 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]);

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.

Aug 01 2021