[LLVMbugs] [Bug 11975] New: -Wformat should change "%x" to "%lx" for a "signed long" argument

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Feb 10 10:13:12 PST 2012


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

             Bug #: 11975
           Summary: -Wformat should change "%x" to "%lx" for a "signed
                    long" argument
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: hans at chromium.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Nico pointed out that the following fix-it seems wrong:

a.cc:4:12: warning: format specifies type 'unsigned int' but the argument has
type
      'long' [-Wformat]
  printf("%x", (signed long) 42);
          ~^   ~~~~~~~~~~~~~~~~
          %ld

The problem is that with this fix-it, we loose the hex formatting.

Strictly speaking, "%lx" expects an unsigned long, but Clang would not warn
about using "%lx" for a signed long (presumably because this is safe in
practice and lots of code relies on it?).

-- 
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