From owner-freebsd-numerics@freebsd.org Tue Jan 1 05:52:30 2019 Return-Path: Delivered-To: freebsd-numerics@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E6760148C56A for ; Tue, 1 Jan 2019 05:52:29 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "troutmask", Issuer "troutmask" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id D2B2576150; Tue, 1 Jan 2019 05:52:27 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id x015qPMi006039 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 31 Dec 2018 21:52:25 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id x015qPVC006038; Mon, 31 Dec 2018 21:52:25 -0800 (PST) (envelope-from sgk) Date: Mon, 31 Dec 2018 21:52:25 -0800 From: Steve Kargl To: Pedro Giffuni Cc: freebsd-numerics@freebsd.org Subject: Re: Undefined Behavior in lib/msun/src/e_pow.c (was Re: New math library from ARM) Message-ID: <20190101055225.GA5982@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu References: <797a7755-db93-1b9c-f3b9-8850d948e098@FreeBSD.org> <20181231151904.GB823@troutmask.apl.washington.edu> <20181231152230.GC823@troutmask.apl.washington.edu> <06c8b6a2-ed26-f255-3947-c79b593a9dea@FreeBSD.org> <20190101045425.GA5767@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Queue-Id: D2B2576150 X-Spamd-Bar: +++ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [3.18 / 15.00]; ARC_NA(0.00)[]; HAS_REPLYTO(0.00)[sgk@troutmask.apl.washington.edu]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_MEDIUM(0.65)[0.654,0]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[washington.edu]; AUTH_NA(1.00)[]; REPLYTO_ADDR_EQ_FROM(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; IP_SCORE(0.16)[ip: (0.45), ipnet: 128.95.0.0/16(0.26), asn: 73(0.18), country: US(-0.08)]; NEURAL_SPAM_SHORT(0.99)[0.986,0]; RCVD_IN_DNSWL_MED(-0.20)[21.76.95.128.list.dnswl.org : 127.0.11.2]; MX_GOOD(-0.01)[cached: troutmask.apl.washington.edu]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_SPAM_LONG(0.69)[0.694,0]; R_SPF_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:73, ipnet:128.95.0.0/16, country:US]; MID_RHS_MATCH_FROM(0.00)[] X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Jan 2019 05:52:30 -0000 On Tue, Jan 01, 2019 at 12:14:38AM -0500, Pedro Giffuni wrote: > > > I'll defer to Bruce on this. My only comments are > > 1) declarations belong at the top of the file where all declarations occur > > Modern standards let you declare variables within blocks. For style we > do prefer to start the function with them but in this case we can't. I'am aware of what modern standards allow. I'm also aware of the code style of fdlibm, which I think should be maintain. > > 2) j is already declared as int32_t > And it has to be a signed integer: we later check for negative values. Yeah, I know. That's why I pointed out the collision. > > 3) uint32_t should be written as u_int32_t. > > No, uint32_t is the standard type, u_int32_t is a BSDism. Also, the file > consistently uses uint32_t. Ah, no. e_pow.c uses u_int32_t on line 107. This would be easy to see if all declarations are grouped together. In additional, don't you need to include stdint.h to get uint32_t? % grep uint32_t /usr/src/lib/msun/src/e_pow.c % grep u_int32_t /usr/src/lib/msun/src/e_pow.c u_int32_t lx,ly; n = ((u_int32_t)hx>>31)-1; Code churn to placate lint for an event that cannot occur seems dubious to me. -- Steve