www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15417] New: Wrong parameter passing for variadic nested

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

          Issue ID: 15417
           Summary: Wrong parameter passing for variadic nested functions
                    within aggregate
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: mathias.lang sociomantic.com
                CC: public dicebot.lv

```
import core.stdc.stdarg;

class C
{
    private void method ()
    {
        void test (ulong c1, ...)
        {
            va_list ap;
            va_start(ap, _argptr);
            assert(char.init == va_arg!(char)(ap));
        }
        test(4242UL, char.init);
    }
}

void main ()
{
    auto c = new C;
    c.method;
}
```

Result in a SEGV:

```
Program received signal SIGSEGV, Segmentation fault.
core.stdc.stdarg.va_arg!(char).va_arg(core.stdc.stdarg.__va_list_tag*, ref
char) (parmn= 0x7fffffffd6c0: 255 '\377', apx=0x0)
    at /usr/include/dmd/druntime/import/core/stdc/stdarg.d:233
233                        if (ap.offset_regs < 6 * 8 && T.sizeof <= 8)
(gdb) bt

char) (parmn= 0x7fffffffd6c0: 255 '\377', apx=0x0)
    at /usr/include/dmd/druntime/import/core/stdc/stdarg.d:233

core.stdc.stdarg.va_arg!(char).va_arg(core.stdc.stdarg.__va_list_tag*) (ap=0x0)
    at /usr/include/dmd/druntime/import/core/stdc/stdarg.d:198

    this=0x7ffff7eec000, _arguments_typeinfo=0x648360 <TypeInfo_B1a.init$>, 
    c1=4242) at vararg.d:11

    at vararg.d:13


```

Tested with struct too.
Tested with 2.066.1, 2.069, and master as of now (v2.069-devel-4afb98f)

--
Dec 07 2015