Johannes Sixt <j.sixt@xxxxxxxxxxxxx> writes: > Edgar Toernig schrieb: >> The second vsnprintf won't work as the first one consumed all args >> from va_list ap. You need to va_copy the ap. > > Your analysis is not correct. The second vsnprintf receives the same > argument pointer as the first, and, hence, consumes the same set of > arguments. C99 7.9.16.2p2 has a footnote: "As the functions vfprintf, vfscanf, vprintf, vscanf, vsnprintf, vsprintf, and vsscanf invoke the va_arg macro, the value of arg after the return is indeterminate." Normative text in 7.15p3 confirms this: "The object ap may be passed as an argument to another function; if that function invokes the va_arg macro with parameter ap, the value of ap in the calling function is indeterminate and shall be passed to the va_end macro prior to any further reference to ap." Therefore va_copy is needed here, at least in principle. - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html