This is the mail archive of the cygwin mailing list for the Cygwin 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]

mingw64-i686-gcc-4.5.3-4: -Wformat warnings broken in C++

When printf/scanf functions from MinGW runtime are selected via __USE_MINGW_ANSI_STDIO, then format string checking is broken. This only affects the C++ compiler:

$ cygcheck -f /usr/bin/i686-w64-mingw32-g++ mingw64-i686-gcc-g++-4.5.3-4

$ cat testfmt.c
#include <stdio.h>

void myprintf(const char *, ...)

int main()
  long long x = 42;
  printf("%lld\n", x); // C++: Bogus warning
  myprintf("%lld\n", x); // No warning (OK)
  printf("%I64d\n", x); // Warning (OK)
  return 0;

$ i686-w64-mingw32-gcc -Wformat -c testfmt.c
testfmt.c: In function 'main':
testfmt.c:12:3: warning: format '%I64d' expects type 'int', but argument 2 has type 'long long int'

$ i686-w64-mingw32-g++ -Wformat -c testfmt.c
testfmt.c: In function 'int main()':
testfmt.c:10:21: warning: unknown conversion type character 'l' in format
testfmt.c:10:21: warning: too many arguments for format
testfmt.c:12:22: warning: format '%I64d' expects type 'int', but argument 2 has type 'long long int'

Interestingly the bogus warning only occurs for standard functions like printf(). These are replaced by inline functions in MinGW stdio.h if __USE_MINGW_ANSI_STDIO is set. Probably a subtle bug in the handling of functions known by the compiler.

Another observation: Include files from C++ standard library (e.g. <string>) now silently set __USE_MINGW_ANSI_STDIO:


Both are new issues not seen in previous releases. If desired, I could resend this report to mingw-w64 list.


-- Problem reports: FAQ: Documentation: Unsubscribe info:

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