From patchwork Wed Sep 4 17:22:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel F. T. Gomes" X-Patchwork-Id: 34385 Received: (qmail 48186 invoked by alias); 4 Sep 2019 17:22:30 -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 48178 invoked by uid 89); 4 Sep 2019 17:22:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=HX-Envelope-From:sk:gabriel, HX-HELO:sk:smtpout, H*F:D*net.br, H*F:D*br X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH] math: Remove const attribute from totalorder* functions Date: Wed, 4 Sep 2019 14:22:19 -0300 Message-ID: <20190904172219.15244-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 17496484552556728003 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduvddrudejhedguddutdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" NOTE: If this is not a bug in glibc, then it might be a bug in gcc (I tested with Debian's gcc and with the toolchain generated by build-many-glibcs with top of the tree binutils, gcc, and glibc as of yesterday). -- 8< -- Since the commit commit 42760d764649ad82f5fe45a26cbdf2c2500409f7 Author: Joseph Myers Date: Thu Aug 15 15:18:34 2019 +0000 Make totalorder and totalordermag functions take pointer arguments. the test case math/test-totalorderl-ldbl-128ibm fails on every input pair, when compiled with -O2, which is the case for glibc test suite. Debugging showed that the test case is passing arguments incorrectly to totalorderl. This can also be inferred by the fact that compiling the test case with -O0 hides the bug. The documentation for the const attribute in GCC manual reads: Note that a function that has pointer arguments and examines the data pointed to must not be declared const if the pointed-to data might change between successive invocations of the function. In general, since a function cannot distinguish data that might change from data that cannot, const functions should never take pointer or, in C++, reference arguments. Likewise, a function that calls a non-const function usually must not be const itself. This commit removes the const attribute from the declarations of all totalorder functions, since the pointed-to data is likely to be changed by user code between invocations of totalorder*. Tested for powerpc64le and x86_64. * math/bits/mathcalls.h (totalorder, totalordermag): Remove const attribute. --- math/bits/mathcalls.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/math/bits/mathcalls.h b/math/bits/mathcalls.h index 66832c7827..1361b55fb6 100644 --- a/math/bits/mathcalls.h +++ b/math/bits/mathcalls.h @@ -373,13 +373,12 @@ __MATHDECL_1 (int, canonicalize,, (_Mdouble_ *__cx, const _Mdouble_ *__x)); #if __GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN /* Total order operation. */ -__MATHDECL_1 (int, totalorder,, (const _Mdouble_ *__x, const _Mdouble_ *__y)) - __attribute__ ((__const__)); +__MATHDECL_1 (int, totalorder,, (const _Mdouble_ *__x, + const _Mdouble_ *__y)); /* Total order operation on absolute values. */ __MATHDECL_1 (int, totalordermag,, (const _Mdouble_ *__x, - const _Mdouble_ *__y)) - __attribute__ ((__const__)); + const _Mdouble_ *__y)); /* Get NaN payload. */ __MATHCALL (getpayload,, (const _Mdouble_ *__x));