Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Mar 2024 10:22:32 +0000
From:      bugzilla-noreply@freebsd.org
To:        toolchain@FreeBSD.org
Subject:   [Bug 277649] clang version 17.0.6 compiles va_list to both integer and structure pointer
Message-ID:  <bug-277649-29464-5Cg32XleEV@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-277649-29464@https.bugs.freebsd.org/bugzilla/>
References:  <bug-277649-29464@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D277649

Dimitry Andric <dim@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |Not A Bug
             Status|New                         |Closed
                 CC|                            |dim@FreeBSD.org

--- Comment #1 from Dimitry Andric <dim@FreeBSD.org> ---
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 doin=
g 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 =3D {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=3D1, Nv;
register int    n, ne;
         char   *cp, *cpr, *fmtp;
         struct a_build_ctrl_t   abc =3D {};
         va_copy(abc.ap, ap);
#define nv      ne
// ...
         va_end(abc.ap); // each va_copy() must be matched with a va_end()
}

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-277649-29464-5Cg32XleEV>