https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88354
Bug ID: 88354 Summary: Please warn on the use of a va_list argument in *printf functions instead of v*printf Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: vincent-gcc at vinc17 dot net Target Milestone: --- A {,f,d,s,sn}printf function can mistakenly be used instead of v{,f,d,s,sn}printf. for instance, this is what happened in atop: https://github.com/Atoptool/atop/pull/43/commits/0e43049493e65b412e1c0def62a09ceac2bb3110 Type checking should warn when this occurs. Implementing the warning is possible because the {,f,d,s,sn}printf functions cannot take a va_list argument, so that this is necessarily an error. An example of buggy code for which one should get a warning: #include <stdio.h> #include <stdarg.h> void f (int i, const char *s, ...) { if (i) { va_list args; va_start (args, s); fprintf (stderr, s, args); va_end (args); } } int main (void) { unsigned long d = 17; f (1, "n = %lu\n", d); return 0; } (The correct code is obtained by replacing fprintf with vfprintf.)