[LLVMbugs] [Bug 12838] New: Suggest "%zu" for sizeof expressions in printf calls

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 15 13:55:15 PDT 2012


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

             Bug #: 12838
           Summary: Suggest "%zu" for sizeof expressions in printf calls
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: matthewbg at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


% clang -fsyntax-only -Wformat -std=c++11 test.cc
test.cc:5:12: warning: format specifies type 'unsigned int' but the argument
has type 'unsigned long' [-Wformat]
  printf("%u\n", sizeof(i));
          ~^     ~~~~~~~~~
          %lu

The standard says that the argument has type size_t, but we apparently think
it's just a long when we're checking the format string.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list