[llvm-bugs] [Bug 36972] New: Missing -Wformat-extra-args warning when calling basename() in printf() argument

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Apr 1 19:12:06 PDT 2018


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

            Bug ID: 36972
           Summary: Missing -Wformat-extra-args warning when calling
                    basename() in printf() argument
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bernie at codewiz.org
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

All versions of clang I tried did not warn about an extra printf argument in
the testcase below.

Fails in: clang 7.0.1, 5.0.1, 3.8.275480
Works in: gcc 7.3.0

Reduced testcase:
--------------------------------------------
#include <stdio.h>
#include <libgen.h>  // basename()

int main(int argc, char** argv) {
    // Fails to emit -Wformat-extra-args diagnostic
    printf("too %s", "many", basename(argv[0]));

    // Works as expected
    printf("too %s", "many", __xpg_basename(argv[0]));
}
--------------------------------------------

-- 
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/20180402/16aeec78/attachment.html>


More information about the llvm-bugs mailing list