https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110712

--- Comment #2 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
(In reply to Richard Biener from comment #1)
> this_2(D)->ap = VIEW_CONVERT_EXPR<struct [1]>(ap_3(D));
> 
> it looks odd since ap_3(D) is a is_gimple_reg but a struct[1] definitely
> would not.  Maybe you are missing a dereference here?  In C
> struct[1] would decay to a pointer so
> 
>  this.ap = ap;
> 
> wouldn't work (besides that va_list copying requires va_copy).

Static arrays in D are passed around by value, rather than decaying to a
pointer. However va_list is an inconsistent type on this front.

In some D compilers, it's always a pointer type to get around the
incompatibility with C/C++ - though this requires locals and fields to be
specially initialized before being passed to va_start() or va_copy().

i.e, underneath the hood it does:
---
void va_start(T)(out va_list ap, ref T parmn,
                 va_list storage = alloca(__va_list_tag.sizeof))
{
    ap = storage;
    // initialize *ap
}

void va_copy(out va_list ap, va_list src,
             va_list storage = alloca(__va_list_tag.sizeof))
{
    ap = storage;
    // copy *src.
}
---

GDC doesn't do this, rather - in a way that mimics C/C++ - va_list static
arrays are decayed to a pointer type when used as a parameter, but semantically
it's still treated as a static array.

I think some extra errors during the D front-end codegen pass are likely the
most appropriate thing to do here, as you say, such things are rejected by
C/C++, so GDC ought to reject them too.

Reply via email to