From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2138) id E10503857715; Mon, 16 Oct 2023 08:01:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E10503857715 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1697443269; bh=ZLe1s6JcTjJ0gowSYD2vaFHSeNItGkrhRMSvxFj0I+k=; h=From:To:Subject:Date:From; b=QD31S1wtXIOVEPXrpoUBGDtqaYx/lCtycZMKMMs2vMd4MGUElmK9CVKmjaVl7iQXw MXIFeAzQRCs40ZgA8hKYUAfI+DXCp2Fag6mXKi7KNDzykpVi1dQoAIiAMW7PPRbF+0 VRCKfHzMf49ScD75jSgUiFlkk36t8nYHejjBgqz4= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Andreas Schwab To: glibc-cvs@sourceware.org Subject: [glibc] Avoid maybe-uninitialized warning in __kernel_rem_pio2 X-Act-Checkin: glibc X-Git-Author: Andreas Schwab X-Git-Refname: refs/heads/master X-Git-Oldrev: 4a829d70ab3bc9e69f3d186471d043e07e0d78d8 X-Git-Newrev: 5aa1ddfcb3374425b7fe9a1389b98a45a47e4a77 Message-Id: <20231016080109.E10503857715@sourceware.org> Date: Mon, 16 Oct 2023 08:01:09 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5aa1ddfcb3374425b7fe9a1389b98a45a47e4a77 commit 5aa1ddfcb3374425b7fe9a1389b98a45a47e4a77 Author: Andreas Schwab Date: Sun Oct 8 18:23:30 2023 +0200 Avoid maybe-uninitialized warning in __kernel_rem_pio2 With GCC 14 on 32-bit x86 the compiler emits a maybe-uninitialized warning: ../sysdeps/ieee754/dbl-64/k_rem_pio2.c: In function '__kernel_rem_pio2': ../sysdeps/ieee754/dbl-64/k_rem_pio2.c:364:20: error: 'fq' may be used uninitialized [-Werror=maybe-uninitialized] 364 | y[0] = fq[0]; y[1] = fq[1]; y[2] = fw; | ~~^~~ This is similar to the warning that is suppressed in the other branch of the switch. Help the compiler knowing that the variable is always initialized, which also makes the suppression obsolete. Diff: --- sysdeps/ieee754/dbl-64/k_rem_pio2.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/sysdeps/ieee754/dbl-64/k_rem_pio2.c b/sysdeps/ieee754/dbl-64/k_rem_pio2.c index 6e2ef5d07b..f75392525c 100644 --- a/sysdeps/ieee754/dbl-64/k_rem_pio2.c +++ b/sysdeps/ieee754/dbl-64/k_rem_pio2.c @@ -300,6 +300,11 @@ recompute: iq[jz] = (int32_t) z; } + /* jz is always nonnegative here, because the result is never zero to + full precision (this function is not called for zero arguments). + Help the compiler to know it. */ + if (jz < 0) __builtin_unreachable (); + /* convert integer "bit" chunk to floating-point value */ fw = __scalbn (one, q0); for (i = jz; i >= 0; i--) @@ -330,16 +335,7 @@ recompute: for (i = jz; i >= 0; i--) fv = math_narrow_eval (fv + fq[i]); y[0] = (ih == 0) ? fv : -fv; - /* GCC mainline (to be GCC 9), as of 2018-05-22 on i686, warns - that fq[0] may be used uninitialized. This is not possible - because jz is always nonnegative when the above loop - initializing fq is executed, because the result is never zero - to full precision (this function is not called for zero - arguments). */ - DIAG_PUSH_NEEDS_COMMENT; - DIAG_IGNORE_NEEDS_COMMENT (9, "-Wmaybe-uninitialized"); fv = math_narrow_eval (fq[0] - fv); - DIAG_POP_NEEDS_COMMENT; for (i = 1; i <= jz; i++) fv = math_narrow_eval (fv + fq[i]); y[1] = (ih == 0) ? fv : -fv;