Typical example:
void foo(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
// might throw, might not. who knows.
bar(fmt, args);
The C++ standard defers to the C standard for the specification of va_start
et al. The C standard has this to say:
7.15.1p1 ...Each invocation of the va_start and va_copy macros shall be matched by a corresponding invocation of the va_end macro in the same function.
Thus, if you exit the function by any means after calling va_start
but before va_end
, your program exhibits undefined behavior.
Yes, wrapping bar
in a try/catch
would help.