X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type; q=dns; s=default; b=fAdl qfc8asMTm52wESCfVAf/XrspDXmqs7faebqis0F8eXcDa37nlOMrhtEUOUanc0tf ddM77bRlvji+d0+TKl7GOENk7tOcmSw9tYc2l7UztwD4hgf5lslmF+W1o3yobgzb OX7MabbASo4CMb2CU6i2JhW0reAKlhmzQLPJtqI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type; s=default; bh=q/wHXMH7Gk GLF9Hs/bw4kykjVOM=; b=CWqsvyWNrvhJJ1OzrmnVQ6x3keeg0u20SjoGkY2Hzg DTTNnf1hDHw936XusB4Y0PIJsJLHY+pIqM6ydCycqc11AAXYeWMIr+Sx0ChW7F3J x4EQBU+WTMyqKLoNmTXUnaR+fjWGZRlN5cYDsFcX2o1wB6mfaA5VHfTckvNyozmv U= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 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 AT redhat DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 056D57D4F0 Subject: Re: bug in lrint [was: FW: Printing long int in C program under cygwin64] To: cygwin AT cygwin DOT com References: <592618e3 DOT 08179d0a DOT 27b5e DOT 4630 AT mx DOT google DOT com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Message-ID: Date: Thu, 25 May 2017 13:17:30 -0500 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 --bBA530V33nCN3VNlsEKFv4dVJW4VB1smg Content-Type: multipart/mixed; boundary="6MlFD4gner2q11T9EeWS1T8S6qnGqjQik"; protected-headers="v1" From: Eric Blake To: cygwin AT cygwin DOT com Message-ID: Subject: Re: bug in lrint [was: FW: Printing long int in C program under cygwin64] References: <592618e3 DOT 08179d0a DOT 27b5e DOT 4630 AT mx DOT google DOT com> In-Reply-To: <592618e3 DOT 08179d0a DOT 27b5e DOT 4630 AT mx DOT google DOT com> --6MlFD4gner2q11T9EeWS1T8S6qnGqjQik Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable 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" -----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--