delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/01/04/17:40:48

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_YG
X-Spam-Check-By: sourceware.org
Message-ID: <4F04D54D.1070808@users.sourceforge.net>
Date: Thu, 05 Jan 2012 06:40:13 +0800
From: JonY <jon_y AT users DOT sourceforge DOT net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080213 Thunderbird/2.0.0.12 Mnenhy/0.7.5.0
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: mingw64-i686-gcc-4.5.3-4: -Wformat warnings broken in C++
References: <4F049AE6 DOT 4000508 AT t-online DOT de>
In-Reply-To: <4F049AE6.4000508@t-online.de>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--------------enig3128FB10175BF4AEE14F64BA
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On 1/5/2012 02:31, Christian Franke wrote:
> 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:
>=20
>=20
> $ cygcheck -f /usr/bin/i686-w64-mingw32-g++
> mingw64-i686-gcc-g++-4.5.3-4
>=20
> $ cat testfmt.c
> #define __USE_MINGW_ANSI_STDIO 1
> #include <stdio.h>
>=20
> void myprintf(const char *, ...)
>   __attribute__((format(gnu_printf,1,2)));
>=20
> int main()
> {
>   long long x =3D 42;
>   printf("%lld\n", x); // C++: Bogus warning
>   myprintf("%lld\n", x); // No warning (OK)
>   printf("%I64d\n", x); // Warning (OK)
>   return 0;
> }
>=20
> $ 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'
>=20
> $ 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'
>=20
>=20
> 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.
>=20
>=20
> Another observation: Include files from C++ standard library (e.g.
> <string>) now silently set __USE_MINGW_ANSI_STDIO:
>=20
> /usr/lib/gcc/i686-w64-mingw32/4.5.3/include/c++/i686-w64-mingw32/bits/os_=
defines.h:
>=20
> ...
> #undef __USE_MINGW_ANSI_STDIO
> #define __USE_MINGW_ANSI_STDIO 1
>=20
>=20
> Both are new issues not seen in previous releases. If desired, I could
> resend this report to mingw-w64 list.
>=20
> Christian
>=20

Yes, please do that. This is an odd problem indeed, maybe a missing
attribute qualifier.

The os_defines.h is done deliberately though, so std::cout and friends
can print 64bit integers properly.



--------------enig3128FB10175BF4AEE14F64BA
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)

iEYEARECAAYFAk8E1VIACgkQp56AKe10wHfi3wCeMEMd9A1UZwJVoHFwWwQ932/0
K1UAnj2vFDN7zzaScNqgsqqm9XniISBX
=LdEi
-----END PGP SIGNATURE-----

--------------enig3128FB10175BF4AEE14F64BA--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019