From patchwork Fri Jan 17 14:44:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matheus Castanho X-Patchwork-Id: 1224874 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108767-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=XgLsi26F; 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 47zkQ45TK5z9sS3 for ; Sat, 18 Jan 2020 01:45:48 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=wg9Tb7YkJI/Tv27/1Fau+F+vGIi1IgjOai+Y85KP+eizL+/5Tw7ey /Ed2b9cOrJAIe5zaSVW69qN2au+yOYTGH9Vme8RXXy5RIcNCH1c/goSBmGtSHTUo OQBVwDJQUotnEFWpd1P9qa4fAo5uLU8gK0U+NPFkkZouGGU0dl0p9s= 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:from:to:cc:subject:date:message-id :mime-version:content-type:content-transfer-encoding; s=default; bh=ybeijiQgUAXzFdNp9Oiirnb85tM=; b=XgLsi26FaJKyY9tyvJIrh7BriJg2 zsWHTj7Qb3pwCPXKDCcS0AKzkH4B05s2nYIDZZrMw/mzjd/AZvgmCB4nioNvCTM/ 6R8sxFAcPCLJ2NZk69kjhLArPnc2tsi9n9CfNUIMkPlYP8zBHcFIdogJqo4NNOum lRWdT0EdaFhlK0Y= Received: (qmail 1569 invoked by alias); 17 Jan 2020 14:45:39 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 1133 invoked by uid 89); 17 Jan 2020 14:45:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=instruct, ze, HX-Languages-Length:1477, HContent-Transfer-Encoding:8bit X-HELO: mx0a-001b2d01.pphosted.com From: Matheus Castanho To: libc-alpha@sourceware.org Cc: joseph@codesourcery.com, siddhesh@sourceware.org Subject: [PATCH v2] Fix maybe-uninitialized error on powerpc Date: Fri, 17 Jan 2020 11:44:54 -0300 Message-Id: <20200117144454.22045-1-msc@linux.ibm.com> MIME-Version: 1.0 Changes for v2: - Use __builtin_unreachable so compiler ignores false-positive - Add comment with proper explanation ----8<---- The build has been failing on powerpc64le-linux-gnu with GCC 10 due to a maybe-uninitialized error: ../sysdeps/ieee754/dbl-64/mpa.c:875:6: error: ‘w.e’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 875 | EY -= EX; | ^~ The warning is thrown because when __inv is called by __dvd *y is not initialized and if t == 0 before calling __dbl_mp, EY will stay uninitialized, as the function does not touch it in this case. However, since t will be set to 1/t before calling __dbl_mp, t == 0 will never happen, so we can instruct the compiler to ignore this case, which suppresses the warning. Tested on powerpc64le. --- sysdeps/ieee754/dbl-64/mpa.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sysdeps/ieee754/dbl-64/mpa.c b/sysdeps/ieee754/dbl-64/mpa.c index 3bb8bff90d..0bcba09e24 100644 --- a/sysdeps/ieee754/dbl-64/mpa.c +++ b/sysdeps/ieee754/dbl-64/mpa.c @@ -871,6 +871,13 @@ __inv (const mp_no *x, mp_no *y, int p) z.e = 0; __mp_dbl (&z, &t, p); t = 1 / t; + + /* t == 0 will never happen at this point, since 1/t can only be 0 if t is + infinity, but before the division t == mantissa of x (exponent is 0). We + can instruct the compiler to ignore this case. */ + if (t == 0) + __builtin_unreachable(); + __dbl_mp (t, y, p); EY -= EX;