math: Replace const attribute with pure in totalorder* functions
commitab41100bab128fa98258aafbb0ab1622884cec4c
authorGabriel F. T. Gomes <gabrielftg@linux.ibm.com>
Wed, 4 Sep 2019 16:36:23 +0000 (4 13:36 -0300)
committerGabriel F. T. Gomes <gabrielftg@linux.ibm.com>
Thu, 5 Sep 2019 14:21:54 +0000 (5 11:21 -0300)
treeeb927e3ee3529154049deb125de47794db42e035
parenta26918cfda4bc4b9dad8aae1496e3ef7cbb63d96
math: Replace const attribute with pure in totalorder* functions

Since the commit

commit 42760d764649ad82f5fe45a26cbdf2c2500409f7
Author: Joseph Myers <joseph@codesourcery.com>
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.

Since the pointed-to data is likely to be changed by user code between
invocations of totalorder*, this patch removes the const attribute from
the declarations of all totalorder functions, replacing it with the pure
attribute, as suggested in the manual:

  The pure attribute imposes similar but looser restrictions on a
  function’s definition than the const attribute: pure allows the
  function to read any non-volatile memory, even if it changes in
  between successive invocations of the function.

Tested for powerpc64le and x86_64.
ChangeLog
math/bits/mathcalls.h