[LLVMbugs] [Bug 18982] New: Feature request: Suppressing -Wformat-nonliteral warning with va_list format argument

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Feb 26 15:58:58 PST 2014


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: unassignedclangbugs at nondot.org
          Reporter: chengniansun at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140226/780f076b/attachment.html>


More information about the llvm-bugs mailing list