[LLVMbugs] [Bug 13565] New: printf format specifiers for different platforms

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Aug 9 08:57:21 PDT 2012


             Bug #: 13565
           Summary: printf format specifiers for different platforms
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: vanboxem.ruben at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Running this code through MinGW-w64 based Clang:
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <fstream>
int main(int argc,char **argv)
   uint64_t val=1234567890;
   printf("%" PRId64"\n",val);
gives following warning:
M:\Development\x64\test>clang++ -std=c++11 test.cpp -c -Wall
test.cpp:11:15: warning: invalid conversion specifier 'I'
   printf("%" PRId64"\n",val);
      expanded from macro 'PRId64'
#define PRId64 "I64d"
1 warning generated.

The PRId64 is defined to a valid msvcrt (Windows C runtime) format specifier,
all of which are documented here:

I dug through the code, and ended up in these files:

Which I believe need a new "case" in the "ParsePrintfSpecifier" function, which
would look somewhat like this:

    case 'I':
        if(triplet.third == "win32" || triplet.third == "mingw32")
            k = ConversionSpecifier::???;

And perhaps similar modifications for the glibc (which would check for glibc
being used) and objc (which should check for objc being used) conversion
specifier. I do not know what ??? should be, nor if this well then be properly
handled, so I'm leaving this to the experts.

I'll gladly test a patch for this, but I'm too stupid and C-agnostic to even
understand what the function in question is doing.

Related mailing list discussion:

PS: for testing on Windows, download the GCC dw2 4.6.3-1
and assorted Clang 3.1
and extract to the same directory. But as I said, I can take care of the
testing myself.

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