[Bug libstdc++/77801] std::experimental::gcd std::experimental::lcd use non-constexpr std::abs

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Sep 30 12:07:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77801

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|WAITING                     |NEW

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
We still require a testcase, as https://gcc.gnu.org/bugs/ explains (which you
were requested to read when created this report).

We have tests that they can be used in constant expressions, which pass:

https://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/testsuite/experimental/numeric/

The problem is that abs(int, int) is declared with attribute((const)) in glibc,
which allows this to work. It doesn't work with other argument types, because
they use the non-constexpr overloads added in <cstdlib>

#include <cstdlib>
#include <experimental/numeric>
constexpr int i = std::experimental::gcd(4L, 5L);

It's also necessary to include <cstdlib> because otherwise I think we get the
floating-point overloads from <cmath> which *are* constexpr.

So the interactions are actually not entirely obvious. Please provide a
testcase next time.


More information about the Gcc-bugs mailing list