https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277649

Dimitry Andric <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |Not A Bug
             Status|New                         |Closed
                 CC|                            |[email protected]

--- Comment #1 from Dimitry Andric <[email protected]> ---
Unfortunately va_list is not a regular type, and you cannot just copy it by
assignment, it requires va_copy(3). So assigning it in the way you are doing is
not possible.

Note that gcc also warns, in the same way:

% gcc -c parsargu.c
parsargu.c: In function 'build_arg_fmt_list':
parsargu.c:19:32: warning: initialization of 'unsigned int' from '__va_list_tag
*' makes integer from pointer without a cast [-Wint-conversion]
   19 | struct a_build_ctrl_t   abc = {ap, 0};
      |                                ^~
parsargu.c:19:32: note: (near initialization for 'abc.ap[0].gp_offset')

What can work is to initialize the struct as completely empty, then va_copy the
incoming va_list into it, e.g.:

void*
build_arg_fmt_list(void* fmt, va_list ap)
{
int     tBE, na=1, Nv;
register int    n, ne;
         char   *cp, *cpr, *fmtp;
         struct a_build_ctrl_t   abc = {};
         va_copy(abc.ap, ap);
#define nv      ne
// ...
         va_end(abc.ap); // each va_copy() must be matched with a va_end()
}

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to