Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to va_end when an exception is thrown?

Tags:

I have a logging framework based on printf-style formatting:

void Logger::debug(const char *fmt, ...) {
    va_list args;
    va_start(args, fmt);
    this->output(DebugLevel, fmt, args);
    va_end(args);
}

If Logger::output throws, will the compiler unwind the stack properly, or do I need to add a try/catch block with va_end(args) in the catch clause? Can this be RAII'ed instead, or is va_end too magic for that? If possible, please include references to the standard.