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
#0  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
#1  0x000000000041f391 in
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
#2  0x000000000041f33b in vararg.C.method().test(ulong, ...) (
    this=0x7ffff7eec000, _arguments_typeinfo=0x648360 <TypeInfo_B1a.init$>, 
    c1=4242) at vararg.d:11
#3  0x000000000041f2d7 in vararg.C.method() (this=0x7ffff7eec000)
    at vararg.d:13
#4  0x000000000041f36a in D main () at vararg.d:20

```

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

--
Dec 07 2015