[Issue 21301] New: Wrong values being passed as variadic arguments

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Oct 10 21:49:59 UTC 2020


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

          Issue ID: 21301
           Summary: Wrong values being passed as variadic arguments
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: cromfr at gmail.com

Since DMD 2.084.0, the following code fails:

```
void main()
{
        void func(T...)(T args){
                // here args[1] is received as [0, 0, 64, 64, 38, 86, 0, 0, 1,
2, 3, 4]
                assert(args[1][0 .. 12] == [1,2,3,4,5,6,7,8,9,10,11,12]);
        }

        func(
                ubyte(0),
                cast(ubyte[12])[1,2,3,4,5,6,7,8,9,10,11,12],
                cast(float[3])[1f,2f,3f],
                0f,
                0f,
                0f,
                0f,
                0f,
                0f,
                0f,
                0f,
                0f,
                uint(0),
                [0,1,2,3,4],
                uint(0),
        );
}
```

This code works correctly on DMD 2.083.1, but fails on 2.084.0 and
2.084.1-beta.

Adding or removing arguments in the func call (like adding one more 0f value)
makes func work correctly and pass its assert.

Changing the value of the first ubyte(0) changes the data received as args[1]
(but still fails on the assert)

args[1] seems to be shifted by 8 bytes

--


More information about the Digitalmars-d-bugs mailing list