http://llvm.org/bugs/show_bug.cgi?id=18982

            Bug ID: 18982
           Summary: Feature request: Suppressing -Wformat-nonliteral
                    warning with va_list format argument
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

For the following code, clang emits a -Wformat-nonliteral warning. 

------------------------------------
$: cat s.c
#include <stdarg.h>
#include <stdio.h>
void foo (const char *msg, ...) {
  va_list ap;
  va_start (ap, msg);
  vfprintf (stderr, msg, ap);
  va_end (ap);
}
------------------------------------

$: clang-trunk -Wformat-nonliteral s.c -c
s.c:6:21: warning: format string is not a string literal [-Wformat-nonliteral]
  vfprintf (stderr, msg, ap);
                    ^~~
1 warning generated.
$: gcc-trunk -Wformat=2 -c s.c
$


IMHO, since it is a wrapper function to printf, it is better to suppress this
warning. I also checked the gcc manual, and gcc specially handles such case. 

-Wformat-nonliteral
    If -Wformat is specified, also warn if the format string is not a string
literal and so cannot be checked, unless the format function takes its format
arguments as a va_list.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to