[Bug 277649] clang version 17.0.6 compiles va_list to both integer and structure pointer
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 12 Mar 2024 10:22:32 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277649 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 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.