From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5832 invoked by alias); 25 May 2017 18:17:31 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 5817 invoked by uid 89); 25 May 2017 18:17:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 25 May 2017 18:17:29 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 056D57D4F0 for ; Thu, 25 May 2017 18:17:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 056D57D4F0 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=eblake@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 056D57D4F0 Received: from [10.10.122.27] (ovpn-122-27.rdu2.redhat.com [10.10.122.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id B33ED6031D for ; Thu, 25 May 2017 18:17:31 +0000 (UTC) Subject: Re: bug in lrint [was: FW: Printing long int in C program under cygwin64] To: cygwin@cygwin.com References: <592618e3.08179d0a.27b5e.4630@mx.google.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Message-ID: Date: Thu, 25 May 2017 19:25:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <592618e3.08179d0a.27b5e.4630@mx.google.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="bBA530V33nCN3VNlsEKFv4dVJW4VB1smg" X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg00417.txt.bz2 --bBA530V33nCN3VNlsEKFv4dVJW4VB1smg Content-Type: multipart/mixed; boundary="6MlFD4gner2q11T9EeWS1T8S6qnGqjQik"; protected-headers="v1" From: Eric Blake To: cygwin@cygwin.com Message-ID: Subject: Re: bug in lrint [was: FW: Printing long int in C program under cygwin64] References: <592618e3.08179d0a.27b5e.4630@mx.google.com> In-Reply-To: <592618e3.08179d0a.27b5e.4630@mx.google.com> --6MlFD4gner2q11T9EeWS1T8S6qnGqjQik Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Content-length: 1113 On 05/24/2017 06:36 PM, Steven Penny wrote: > On Wed, 24 May 2017 07:33:27, Eric Blake wrote: >> Buggy. size_t should be printed with %zi, not %i (since size_t and int >> are not necessarily the same type). >=20 > Aren=E2=80=99t both wrong? By definition %i is a signed integer, and size= _t is > unsigned. > So %zu Correct. Newer gcc's -Wformat-signedness will flag the discrepency. > or %llu would be more correct: NO. Do NOT use %llu with size_t, because it is not portable to 32-bit platforms. That's WHY %zu exists. > They all seem to do the job though: Yes. On all modern platforms, you can freely mix signed and unsigned integers and get correct (when the number is positive and does not exceed the signed maximum) or at least sane results (2s complement counterpart for all other values) regardless of which direction you mess with incorrect signedness. However, such behavior is technically not required by the C standard, which is why gcc added -Wformat-signedness. --=20 Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org --6MlFD4gner2q11T9EeWS1T8S6qnGqjQik-- --bBA530V33nCN3VNlsEKFv4dVJW4VB1smg Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" Content-length: 604 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJZJx+6AAoJEKeha0olJ0NqEmsH/1pMgmP41RJP4DSwXdg/29HJ 15OG6S9LKPJZ2KG0XFy5RNU/lu9ek4qbwXShqCR+i/ugtl0xWpTnDZN92PVmd8S1 br1+4tNYoUp57U+ZabLDBedgyTXZNnIUt/Vo6bvuPyW9w9BS6WzQURoSy5jnW8eZ UM/iSBJDhZcduP6ww2inf7yZ4lOHo7McaKNpezs+pbiTxG3lKjynDMdG+ADz/Cjx +dTK/RSnRKTDFLv4S1BICu8Zc+9MB+yV6c8+p/7/DjiUcDaQCTRcILt/nRcerdhu gqlv2vTe5HN3J57+U4q5LrNd9IgEOQ4raNz+M/Rp5b0ohnBRbmHWlnA+OZ5nVaU= =kuU9 -----END PGP SIGNATURE----- --bBA530V33nCN3VNlsEKFv4dVJW4VB1smg--