[Issue 19672] New: Function uses the stack to read a static array parameter but it is passed in the registers

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 12 21:11:12 UTC 2019


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

          Issue ID: 19672
           Summary: Function uses the stack to read a static array
                    parameter but it is passed in the registers
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: b2.temp at gmx.com

```
struct S
{
    ulong c;
    bool b;                  // removing this prevents bug
}

// increase the struct size at least to 17 bytes also prevents the bug.

void main()
{
    S[1] a = [S(42)];
    assert(a[0].c == 42); /* Passes. */
    f(a);
}

void f(S[1] a)
{
    assert(a[0].c == 42); /* Fails. */
}
```

After inspection of the produced asm it appeared that the parameter `a` is
passed in the registers RDI (a[0].c) and RSI (a[0].b) but when reading the
value for the assertion the stack is used instead (proof :
https://forum.dlang.org/post/modqrqwsqvhxodtlickm@forum.dlang.org).

--


More information about the Digitalmars-d-bugs mailing list