From owner-svn-src-all@FreeBSD.ORG Fri Oct 31 23:41:29 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AFE5AD55; Fri, 31 Oct 2014 23:41:29 +0000 (UTC) Received: from mho-02-ewr.mailhop.org (mho-02-ewr.mailhop.org [204.13.248.72]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7C9AE633; Fri, 31 Oct 2014 23:41:29 +0000 (UTC) Received: from [73.34.117.227] (helo=ilsoft.org) by mho-02-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1XkLot-000Cjb-LM; Fri, 31 Oct 2014 23:41:27 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by ilsoft.org (8.14.9/8.14.9) with ESMTP id s9VNfP4I086083; Fri, 31 Oct 2014 17:41:26 -0600 (MDT) (envelope-from ian@FreeBSD.org) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 73.34.117.227 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX19kc7ugBiFf3qtJymHQ9VJt X-Authentication-Warning: paranoia.hippie.lan: Host revolution.hippie.lan [172.22.42.240] claimed to be [172.22.42.240] Subject: Re: svn commit: r273734 - head/bin/dd From: Ian Lepore To: Garrett Cooper In-Reply-To: References: <201410271138.s9RBcHrA002447@svn.freebsd.org> <20141027153957.GZ1877@kib.kiev.ua> <20141027155427.GM1492@f10.opsec.eu> <86vbn4egjt.fsf@nine.des.no> <20141028200418.E849@besplex.bde.org> <86mw8ged20.fsf@nine.des.no> <20141028210830.L1034@besplex.bde.org> Content-Type: text/plain; charset="iso-8859-13" Date: Fri, 31 Oct 2014 17:41:25 -0600 Message-ID: <1414798885.17308.198.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by ilsoft.org id s9VNfP4I086083 Cc: src-committers@freebsd.org, Bruce Evans , svn-src-all@freebsd.org, svn-src-head@freebsd.org, Kurt Jaeger , Konstantin Belousov , Dag-Erling =?ISO-8859-1?Q?Sm=F8rgrav?= X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Oct 2014 23:41:29 -0000 On Fri, 2014-10-31 at 14:30 -0700, Garrett Cooper wrote: > On Oct 28, 2014, at 4:33, Bruce Evans wrote: >=20 > > On Tue, 28 Oct 2014, [utf-8] Dag-Erling Sm=B8rgrav wrote: > >=20 > >> Bruce Evans writes: > >>> Dag-Erling Sm=B8rgrav writes: > >>>> This is a bug on all platforms, and both clang and (recent) gcc > >>>> should complain about it. That printf() call will print garbage. > >>> No, this is only a bug on 32-bit arches. The is is SSIZE_MAX. > >>=20 > >> If you mean "it only has consequences on 32-bit arches", then I agre= e - > >> but it is still a bug to pass an int to %jd. > >=20 > > This is machine-dependent. intmax_t may be int. The only requiremen= t > > on intmax_t is that it can represent any value of any signed integer > > type. This is possible if the largest integer type is 64 bits (the > > smallest permitted largest type) and int is also 64 bits (and there > > are no complications for padding bits). intmax_t can even be signed > > char if that is wide enough (not in POSIX starting 10-15 years ago, > > since signed char is now required to be 8 bits. It is weird for > > intmax_t to have the lowest rank (not counting Bool), but FreeBSD use= s > > this loophole to make it have second highest rank on 64-bit arches. >=20 > Indeed. For some giggles, look at this bug: https://bugs.freebsd.org/bu= gzilla/show_bug.cgi?id=3D191674 ("printf("%tu", (intmax_t)-1) returns UIN= T64_MAX on i386, not UINT32_MAX=A1). > Cheers, Isn't the problem in that bug that the cast doesn't match the printf format, and the correct code would be something like the following? printf("%tu", (ptrdiff_t)-1); -- Ian