This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/77801] std::experimental::gcd std::experimental::lcd use non-constexpr std::abs
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 30 Sep 2016 12:07:12 +0000
- Subject: [Bug libstdc++/77801] std::experimental::gcd std::experimental::lcd use non-constexpr std::abs
- Auto-submitted: auto-generated
- References: <bug-77801-4@http.gcc.gnu.org/bugzilla/>
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.