From owner-svn-src-all@FreeBSD.ORG Fri Oct 31 23:09:54 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 5D94981E; Fri, 31 Oct 2014 23:09:54 +0000 (UTC) Received: from h2.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "funkthat.com", Issuer "funkthat.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 2E448136; Fri, 31 Oct 2014 23:09:53 +0000 (UTC) Received: from h2.funkthat.com (localhost [127.0.0.1]) by h2.funkthat.com (8.14.3/8.14.3) with ESMTP id s9VN9lSm045630 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 31 Oct 2014 16:09:47 -0700 (PDT) (envelope-from jmg@h2.funkthat.com) Received: (from jmg@localhost) by h2.funkthat.com (8.14.3/8.14.3/Submit) id s9VN9lCE045629; Fri, 31 Oct 2014 16:09:47 -0700 (PDT) (envelope-from jmg) Date: Fri, 31 Oct 2014 16:09:47 -0700 From: John-Mark Gurney To: Garrett Cooper Subject: Re: svn commit: r273734 - head/bin/dd Message-ID: <20141031230947.GT8852@funkthat.com> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Operating-System: FreeBSD 7.2-RELEASE i386 X-PGP-Fingerprint: 54BA 873B 6515 3F10 9E88 9322 9CB1 8F74 6D3F A396 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html X-TipJar: bitcoin:13Qmb6AeTgQecazTWph4XasEsP7nGRbAPE X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.2 (h2.funkthat.com [127.0.0.1]); Fri, 31 Oct 2014 16:09:48 -0700 (PDT) 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:09:54 -0000 Garrett Cooper wrote this message on Fri, Oct 31, 2014 at 14:30 -0700: > On Oct 28, 2014, at 4:33, Bruce Evans wrote: > > > On Tue, 28 Oct 2014, [utf-8] Dag-Erling Smørgrav wrote: > > > >> Bruce Evans writes: > >>> Dag-Erling Smørgrav 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. > >> > >> If you mean "it only has consequences on 32-bit arches", then I agree - > >> but it is still a bug to pass an int to %jd. > > > > This is machine-dependent. intmax_t may be int. The only requirement > > 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 uses > > this loophole to make it have second highest rank on 64-bit arches. > > Indeed. For some giggles, look at this bug: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=191674 ("printf("%tu", (intmax_t)-1) returns UINT64_MAX on i386, not UINT32_MAX?). That isn't surprising.. because you're sign extending -1 via intmax_t... Even if you didn't mix unsigned and signed in your printf, and casted to uintmax_t, you'd still get UINT64_MAX... This is just how casting of signed numbers work and conversion from signed to unsigned... The bug (from 191674) is in [SU]JARG casting ptrdiff_t to intmax_t if anywhere... It should be cast to the correct intXX_t sized value instead.. In the SJARG case, a simple cast to ptrdiff_t is sufficient.. Now bde will have better idea on the UJARG case, but that needs to go be casted to uintXX_t, and no further casting is needed... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."