#2190 %lld works in latest Windows and is specified in C++11 standard, but MinGW still gives warning when -Wformat is enabled


On latest Windows, %lld works just fine. As I know, it depends on msvcrt.dll version and MSDN says that %lld is supported since Visual Studio 2008: link for 2003 and for 2008.

Of course, %lld works in GCC then, but it gives me warning when -Wformat is enabled, which gives me headache. Moreover, %lld is defined in C++11 standard so it'll be very useful if GCC won't give me false warnings if I either have new msvcrt or С++11.


  • Keith Marshall

    Keith Marshall - 2014-03-05
    • status: unread --> closed
    • Resolution: none --> wont-fix
  • Keith Marshall

    Keith Marshall - 2014-03-05

    We will not fix this; if you wish to follow it up further, please raise the issue directly on the GCC bug tracker.

    FWIW, I've always considered -Wformat to be worse than useless, on the Windows platform; not only does it have to contend, hopelessly, with various Microsoft inconsistencies, but it utterly ignores MinGW.org's own replacement printf implementation, (which you must use, if you wish to print long doubles at their full 80-bit precision; with Microsoft's implementation, you must cast them down to 64-bit doubles). I discussed this with Danny Smith, who at the time was one of the Windows platform development leads for GCC, when -Wformat was introduced, (around the same time as MinGW.org's printf); we never really achieved a consensus of opinion. My advice is: don't enable -Wformat for Windows builds.

  • Egor Suvorov

    Egor Suvorov - 2014-03-05

    What about %Lf and long double then? It's defined in C++11 standard, and there is well-known misunderstanding between MinGW and msvcrt about how long long double is (80 vs 64 bits), which leads to unability to read long doubles. However, I still can print long doubles with printf (but again, -Wformat gives me false warnings, and ignoring warnings is a bad practice, as you know) if I use C++11. Try the code from attachment - if you compile it with C++03, it don't do anything good with long doubles, with if you compile it with C++11, it works exactly as standard defines - %f and %lf for double, %Lf for long double, doesn't it?

    This looks like a bug, because Linux version of GCC accepts %Lf in C++11 mode.

  • Keith Marshall

    Keith Marshall - 2014-03-05

    Comparisons with Linux are completely irrelevant; Linux is a POSIX/ISO-C conformant platform -- Windows is not, never has been, and does not aspire to be. You're having a laugh, when you suggest that you might anticipate C++11 compatibility from MSVCRT; it isn't even C89 compatible!

    As far as doubles go, %Lf works just fine in MinGW.org's printf implementation; it is not reliable, in Microsoft's.

    If you want to proclaim "bug", you must convince the GCC maintainers, because any resolution must come from them.