From patchwork Sat Sep 29 19:39:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jansa X-Patchwork-Id: 976699 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=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-96161-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="T3uVP1Uq"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iexQTPzw"; 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 42MzQ12D2lz9s3Z for ; Sun, 30 Sep 2018 05:39:21 +1000 (AEST) 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:in-reply-to :references; q=dns; s=default; b=pGODq7i1VrfXtbNFlaXoqXwN8kgedGd gbVGXBxWO+lZARagVG8Fx1VrkZGWERPh5HaXVHfvm4warbEVFuTftb4z93DlS4bB NVTg503knhr1q+TMlfLNqJO37C9D+ksJ5C16I8LR3Vk4Mt8TyrsOoifjt3MSwNXu 6GJDCvWZ8teU= 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:in-reply-to :references; s=default; bh=DBOoKvbwrUHjfuOvHpolKQG2Gdc=; b=T3uVP 1UqZERi1Sb4i88naZk6h9lzWM45arxa93pxrtMKpxaDqOZ92/aqzRtNDQsFwx76m eJhXM9Os/o4GvLdXYz9NjyjSbIVc2bYLlRVZ59k7KZmwuWbnUEuyNzNnOvm95sam Wo84Vj65Z+KuSkTnty9GjVfLzGuPuPS2FVGVM0= Received: (qmail 98653 invoked by alias); 29 Sep 2018 19:39:14 -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 98634 invoked by uid 89); 29 Sep 2018 19:39:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=VRP, vrp, PPC X-HELO: mail-wm1-f54.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oZIayU5yrJfelFe2JwfbveBXTy3CA76ywiN0WAj1PpU=; b=iexQTPzwgZk4AxS9LkFQbE8ZIJBR342mi7JP5LtJrzKttxvIFVzcXgXA/oEw0COMC3 bVsy0tkYjv1NSC29uPk7cPSKjsImUdvuc2OwhHKKlf9CAIzDRGdAvDw9PGhLF7kqFWcN dp25GC/m1oWxd+4CZRaV9cJJqZ2xPJGcQkQ+ydqt4Hj+xWCU/ZzwhjfxJ6v5qgY3QWKp iIZbb9boj4cUV2xam1n5m9G8KfzwYk1YT7pzXgjqY+mMOvBCmMLHwif9aJxooZ17LS/R 8lwL3ftKdIwJUAGuM2jm31QHp9kuWa//BXLKEqWVrfc8YUopYzv8XoWDiJocHAHkZ6nR Yjxw== From: Martin Jansa To: libc-alpha@sourceware.org Cc: Martin Jansa Subject: [PATCHv3] sysdeps/ieee754: prevent maybe-uninitialized errors [BZ #19444] Date: Sat, 29 Sep 2018 19:39:07 +0000 Message-Id: <20180929193908.8545-1-Martin.Jansa@gmail.com> In-Reply-To: References: With -O included in CFLAGS it fails to build with: ../sysdeps/ieee754/ldbl-96/e_jnl.c: In function '__ieee754_jnl': ../sysdeps/ieee754/ldbl-96/e_jnl.c:146:20: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized] b = invsqrtpi * temp / sqrtl (x); ~~~~~~~~~~^~~~~~ ../sysdeps/ieee754/ldbl-96/e_jnl.c: In function '__ieee754_ynl': ../sysdeps/ieee754/ldbl-96/e_jnl.c:375:16: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized] b = invsqrtpi * temp / sqrtl (x); ~~~~~~~~~~^~~~~~ ../sysdeps/ieee754/dbl-64/e_jn.c: In function '__ieee754_jn': ../sysdeps/ieee754/dbl-64/e_jn.c:113:20: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized] b = invsqrtpi * temp / sqrt (x); ~~~~~~~~~~^~~~~~ ../sysdeps/ieee754/dbl-64/e_jn.c: In function '__ieee754_yn': ../sysdeps/ieee754/dbl-64/e_jn.c:320:16: error: 'temp' may be used uninitialized in this function [-Werror=maybe-uninitialized] b = invsqrtpi * temp / sqrt (x); ~~~~~~~~~~^~~~~~ Build tested with Yocto for ARM, AARCH64, X86, X86_64, PPC with -O, -O1, -Os. For soft-fp ARM it needs one more fix for -O1: https://sourceware.org/ml/libc-alpha/2018-09/msg00300.html For AARCH64 it needs one more fix for -Os. [BZ #23716] * sysdeps/ieee754/dbl-96/e_jnl.c: Fix build with -O * sysdeps/ieee754/ldbl-96/e_jnl.c: Likewise. * sysdeps/ieee754/ldbl-128/e_jnl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/e_jnl.c: Likewise. Signed-off-by: Martin Jansa --- ChangeLog | 7 +++++++ sysdeps/ieee754/dbl-64/e_jn.c | 21 +++++++++++++++++++++ sysdeps/ieee754/ldbl-128/e_jnl.c | 21 +++++++++++++++++++++ sysdeps/ieee754/ldbl-128ibm/e_jnl.c | 21 +++++++++++++++++++++ sysdeps/ieee754/ldbl-96/e_jnl.c | 21 +++++++++++++++++++++ 5 files changed, 91 insertions(+) diff --git a/ChangeLog b/ChangeLog index 07760299e6..4bafeefda5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2018-09-29 Martin Jansa + Partial fix for [BZ #23716] + * sysdeps/ieee754/dbl-96/e_jnl.c: Fix build with -O + * sysdeps/ieee754/ldbl-96/e_jnl.c: Likewise. + * sysdeps/ieee754/ldbl-128/e_jnl.c: Likewise. + * sysdeps/ieee754/ldbl-128ibm/e_jnl.c: Likewise. + 2018-09-28 Joseph Myers * math/fromfp.h: Do not include . diff --git a/sysdeps/ieee754/dbl-64/e_jn.c b/sysdeps/ieee754/dbl-64/e_jn.c index aff06ead16..20c8ff4f8f 100644 --- a/sysdeps/ieee754/dbl-64/e_jn.c +++ b/sysdeps/ieee754/dbl-64/e_jn.c @@ -43,6 +43,7 @@ #include #include #include +#include static const double invsqrtpi = 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */ @@ -110,7 +111,17 @@ __ieee754_jn (int n, double x) case 2: temp = -c - s; break; case 3: temp = c - s; break; } +/* With GCC 8 (and older) when compiling with -O the compiler + warns that the variable 'temp', may be used uninitialized. + The switch above covers all possible values of n & 3 + but GCC without VRP enabled isn't able to figure out the + range of possible values is [0,3] as explained in: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230 + so it's false possitive with -O1 and lower. */ +DIAG_PUSH_NEEDS_COMMENT; +DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); b = invsqrtpi * temp / sqrt (x); +DIAG_POP_NEEDS_COMMENT; } else { @@ -317,7 +328,17 @@ __ieee754_yn (int n, double x) case 2: temp = -s + c; break; case 3: temp = s + c; break; } +/* With GCC 8 (and older) when compiling with -O the compiler + warns that the variable 'temp', may be used uninitialized. + The switch above covers all possible values of n & 3 + but GCC without VRP enabled isn't able to figure out the + range of possible values is [0,3] as explained in: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230 + so it's false possitive with -O1 and lower. */ +DIAG_PUSH_NEEDS_COMMENT; +DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); b = invsqrtpi * temp / sqrt (x); +DIAG_POP_NEEDS_COMMENT; } else { diff --git a/sysdeps/ieee754/ldbl-128/e_jnl.c b/sysdeps/ieee754/ldbl-128/e_jnl.c index 7610d18c67..fa49f72844 100644 --- a/sysdeps/ieee754/ldbl-128/e_jnl.c +++ b/sysdeps/ieee754/ldbl-128/e_jnl.c @@ -62,6 +62,7 @@ #include #include #include +#include static const _Float128 invsqrtpi = L(5.6418958354775628694807945156077258584405E-1), @@ -151,7 +152,17 @@ __ieee754_jnl (int n, _Float128 x) temp = c - s; break; } +/* With GCC 8 (and older) when compiling with -O the compiler + warns that the variable 'temp', may be used uninitialized. + The switch above covers all possible values of n & 3 + but GCC without VRP enabled isn't able to figure out the + range of possible values is [0,3] as explained in: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230 + so it's false possitive with -O1 and lower. */ +DIAG_PUSH_NEEDS_COMMENT; +DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); b = invsqrtpi * temp / sqrtl (x); +DIAG_POP_NEEDS_COMMENT; } else { @@ -387,7 +398,17 @@ __ieee754_ynl (int n, _Float128 x) temp = s + c; break; } +/* With GCC 8 (and older) when compiling with -O the compiler + warns that the variable 'temp', may be used uninitialized. + The switch above covers all possible values of n & 3 + but GCC without VRP enabled isn't able to figure out the + range of possible values is [0,3] as explained in: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230 + so it's false possitive with -O1 and lower. */ +DIAG_PUSH_NEEDS_COMMENT; +DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); b = invsqrtpi * temp / sqrtl (x); +DIAG_POP_NEEDS_COMMENT; } else { diff --git a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c b/sysdeps/ieee754/ldbl-128ibm/e_jnl.c index 50b4558e74..1f8fd36cb8 100644 --- a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c +++ b/sysdeps/ieee754/ldbl-128ibm/e_jnl.c @@ -62,6 +62,7 @@ #include #include #include +#include static const long double invsqrtpi = 5.6418958354775628694807945156077258584405E-1L, @@ -151,7 +152,17 @@ __ieee754_jnl (int n, long double x) temp = c - s; break; } +/* With GCC 8 (and older) when compiling with -O the compiler + warns that the variable 'temp', may be used uninitialized. + The switch above covers all possible values of n & 3 + but GCC without VRP enabled isn't able to figure out the + range of possible values is [0,3] as explained in: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230 + so it's false possitive with -O1 and lower. */ +DIAG_PUSH_NEEDS_COMMENT; +DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); b = invsqrtpi * temp / sqrtl (x); +DIAG_POP_NEEDS_COMMENT; } else { @@ -387,7 +398,17 @@ __ieee754_ynl (int n, long double x) temp = s + c; break; } +/* With GCC 8 (and older) when compiling with -O the compiler + warns that the variable 'temp', may be used uninitialized. + The switch above covers all possible values of n & 3 + but GCC without VRP enabled isn't able to figure out the + range of possible values is [0,3] as explained in: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230 + so it's false possitive with -O1 and lower. */ +DIAG_PUSH_NEEDS_COMMENT; +DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); b = invsqrtpi * temp / sqrtl (x); +DIAG_POP_NEEDS_COMMENT; } else { diff --git a/sysdeps/ieee754/ldbl-96/e_jnl.c b/sysdeps/ieee754/ldbl-96/e_jnl.c index 855190841b..60964fa887 100644 --- a/sysdeps/ieee754/ldbl-96/e_jnl.c +++ b/sysdeps/ieee754/ldbl-96/e_jnl.c @@ -62,6 +62,7 @@ #include #include #include +#include static const long double invsqrtpi = 5.64189583547756286948079e-1L, two = 2.0e0L, one = 1.0e0L; @@ -144,7 +145,17 @@ __ieee754_jnl (int n, long double x) temp = c - s; break; } +/* With GCC 8 (and older) when compiling with -O the compiler + warns that the variable 'temp', may be used uninitialized. + The switch above covers all possible values of n & 3 + but GCC without VRP enabled isn't able to figure out the + range of possible values is [0,3] as explained in: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230 + so it's false possitive with -O1 and lower. */ +DIAG_PUSH_NEEDS_COMMENT; +DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); b = invsqrtpi * temp / sqrtl (x); +DIAG_POP_NEEDS_COMMENT; } else { @@ -373,7 +384,17 @@ __ieee754_ynl (int n, long double x) temp = s + c; break; } +/* With GCC 8 (and older) when compiling with -O the compiler + warns that the variable 'temp', may be used uninitialized. + The switch above covers all possible values of n & 3 + but GCC without VRP enabled isn't able to figure out the + range of possible values is [0,3] as explained in: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69230 + so it's false possitive with -O1 and lower. */ +DIAG_PUSH_NEEDS_COMMENT; +DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); b = invsqrtpi * temp / sqrtl (x); +DIAG_POP_NEEDS_COMMENT; } else {