This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/60434] New: False -Wformat warnings about %lld and %Lf are given on Windows


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60434

            Bug ID: 60434
           Summary: False -Wformat warnings about %lld and %Lf are given
                    on Windows
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: egor_suvorov at mail dot ru

As you know, C++11 defines %Lf for writing and reading long double and %lf/%f
for double. I can successfully use them in printf in MinGW, but it gives me
false warnings when -Wformat enabled. However, it clearly knows something about
formatting, because if I disable C++11 standard, behavior is changed.

Consider the following example:

#include <cstdio>

int main() {
  long double x = 123.45;
  printf("%f\n", x);  // Undefined
  printf("%lf\n", x); // Undefined
  printf("%Lf\n", x); // Expected '123.45' in C++11

  double y = x;
  printf("%f\n", y);  // Expected '123.45' in C++11
  printf("%lf\n", y); // Expected '123.45' in C++03/C++11
  printf("%Lf\n", y); // Undefined
  return 0;
}

It works when compiling with C++11 or C++03, but it works exactly is it should
to the corresponding standard. Looks like GCC's warnings system does not know
about 'L' modifier in C++11 and consider it spoiled.

I've already <a href="https://sourceforge.net/p/mingw/bugs/2190/";>reported</a>
this to MinGW team and they told me to redirect my report here.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]