[llvm-bugs] [Bug 41153] New: warning: format string is not a string literal with default parameter

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 20 07:04:37 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41153

            Bug ID: 41153
           Summary: warning: format string is not a string literal  with
                    default parameter
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: Mario.Klebsch at ime-actia.de
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

The following code produces a warning, which IMHO is wrong:

mkl at C707 ~ $ cat clang-bug.cpp

void Log(const char* str = " ", ...) __attribute__ ((format (printf, 1, 2)));

void Bug()
{
    Log();
}

mkl at C707 ~ $ /usr/lib/llvm/9/bin/clang++ -c clang-bug.cpp
warning: format string is not a string literal (potentially insecure)
[-Wformat-security]
note: treat the string as an argument to avoid this
1 warning generated.
mkl at C707 ~ $ /usr/lib/llvm/9/bin/clang++ --version
clang version 9.0.0 (/var/tmp/portage/sys-devel/clang-9999/work/x/y/clang-9999
b4f4320de39f9a7227af0a8374c6739af6969f7a)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/9/bin
mkl at C707 ~ $

The warning doesn’t include a line number and disappears when I add the default
argument to Log().

-- 
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/20190320/721a9a39/attachment.html>


More information about the llvm-bugs mailing list