In the following function, I initialize args
, use them in the call to va_start
, and then call va_end
.
The code looks right to me, but clang-tidy gives a warning:
tmp2.c:7:11: error: Function 'vsnprintf' is called with an uninitialized va_list argument [clang-analyzer-valist.Uninitialized,-warnings-as-errors]
len = vsnprintf((void*)0, 0, format, args);
#include<stdarg.h>
#include<stdio.h>
int f(char *format, ...) {
int len;
va_list args;
va_start(args, format);
len = vsnprintf((void*)0, 0, format, args);
va_end(args);
return len;
}
Even more strangely, this only occurs when I lint multiple files at a time, so clang-tidy tmp2.c
does not give a warning, but clang-tidy tmp2.c tmp2.c
does!
Is this a problem with my code or with clang-tidy? I am using LLVM version 7.0.0, but the warning also occurs with 8.0.0.