From patchwork Wed Aug 9 17:15:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 799893 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-460126-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ZTwPmTp/"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xSHwz3GbNz9s03 for ; Thu, 10 Aug 2017 03:16:18 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=sCLIKTdIjo3//U/FX8s7yOqlPt/3xbjqhrd+WeYRU9He8z w5OBF3boWy1v0rPhGkmmoBH2dQWP+ZTXCggpygIN7mE+jRsBF/h46kKqVEw3ziDJ tYw0KYpHWNrtM5Dc2Ffoy6oVvHQSLsDxwD+zWX181OqGvxam4nXer5VnOa6+M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=gDstLUroiggAIKlfDVtDtt5+xqI=; b=ZTwPmTp/HmUrU7fNTWdk +6fD0kEP77eXbxELVVYs/jCfkc6YPuQJgCc10qmKHCA0cq3QPYoH5NFkACKHYoMl 52wRnV3cYfsR1ZnixzgC2enaF7z9fErs3oY4VzHCq+pYQ5S8QPickkXnLd26w0Va Fw/OaimutiveLE98NtK45sg= Received: (qmail 107132 invoked by alias); 9 Aug 2017 17:15:54 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 106770 invoked by uid 89); 9 Aug 2017 17:15:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Than X-HELO: mail-pf0-f178.google.com Received: from mail-pf0-f178.google.com (HELO mail-pf0-f178.google.com) (209.85.192.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 09 Aug 2017 17:15:11 +0000 Received: by mail-pf0-f178.google.com with SMTP id o86so30394686pfj.1 for ; Wed, 09 Aug 2017 10:15:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=BOaa9eBDESH2hbuz4RC6OwLEQCVsPNeBUXO29LeG9/M=; b=sBXj6FUZmR+PVtaiFG0hvZV1Cqd+PpOXj3c5FAiMJSKaWfVTIj67/qMvCVl/qRRgCP eWC8DY7cMw3Rr/pHhHhFZLFhdZQ65IgGZmPpN0SFMKQZMEhQNcsMt4nDyfETWzQ7cMDY Z5PVCC+wfEDX6uMM9gyeiSqFXCtprwWzFlFqImm94QGtA3nMN6rTM2DIX+jjKT/IcAJz EEMiNzj0pCnCP5xRD8Fs68yjxA2S9ANaHV6grR2mHzS258AqmEz5tbBovFk9ZLTjBD97 nDL/4qOqIdLSVIumx5rOEqR+yMlSyl8nGLug4FyLJOp3JLGH/YmGXlmmI20y4aQldyUz 3ahg== X-Gm-Message-State: AHYfb5g8wzLv54JQKcaT9/BQi/HnpPG8PTgiDhtan1e4v0f6F8WwtKYR 2x+xGwJv7/t+4vurvlvcc+omAL1Wgxnfxvo= X-Received: by 10.99.9.67 with SMTP id 64mr8530119pgj.12.1502298906334; Wed, 09 Aug 2017 10:15:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.149.12 with HTTP; Wed, 9 Aug 2017 10:15:05 -0700 (PDT) From: Ian Lance Taylor Date: Wed, 9 Aug 2017 10:15:05 -0700 Message-ID: Subject: libgo patch committed: Fix math.Ldexp for large powers To: gcc-patches , "gofrontend-dev@googlegroups.com" The libgo implementation of math.Ldexp declared the libc "ldexp" as taking an 'int' exponent argument, which is not quite right for 64-bit platforms (exp arg is always int32); this could yield incorrect results for exponent values outside the range of Minint32/Maxint32. This patch by Than McIntosh fixes this by upating the type for the libc version of ldexp, and adding guards to screen for out-of-range exponents. This fixes https://golang.org/issue/21323. Bootstrapped and ran Go tests on x86_64-pc-linux-gnu. Committed to mainline. Ian Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 250873) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -db685a1a9aa8b3b916dd6d1284895e01d73158e1 +5fd112e5c2968e94761c41519c451d789e23a92b The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/go/math/ldexp.go =================================================================== --- libgo/go/math/ldexp.go (revision 250873) +++ libgo/go/math/ldexp.go (working copy) @@ -13,10 +13,15 @@ package math // Ldexp(NaN, exp) = NaN //extern ldexp -func libc_ldexp(float64, int) float64 +func libc_ldexp(float64, int32) float64 func Ldexp(frac float64, exp int) float64 { - r := libc_ldexp(frac, exp) + if exp > MaxInt32 { + exp = MaxInt32 + } else if exp < MinInt32 { + exp = MinInt32 + } + r := libc_ldexp(frac, int32(exp)) return r }