[PATCH] Define 3-argument overloads of std::hypot for C++17 (P0030R1)

Jonathan Wakely jwakely@redhat.com
Thu Sep 29 10:40:00 GMT 2016


On 29/09/16 10:10 +0100, Jonathan Wakely wrote:
>On 29/09/16 10:54 +0200, Rainer Orth wrote:
>>Hi Jonathan,
>>
>>>This adds the new 3D std::hypot() functions. This implementation seems
>>>to be faster than the naïve sqrt(x*x + y*y + z*z) implementation, or
>>>hypot(hypot(x, y), z), and should be a bit more accurate at very large
>>>or very small values due to reducing the arguments by the largest one.
>>>Improvements welcome though, as this is not my forte.
>>>
>>>The test might not be very good, but tests some small integer values
>>>and some other values where accuracy is lost for one or other of the
>>>alternative implementations mentioned above. If this FAILs for some
>>>32-bit targets we might need to adjust the tolerances or the
>>>dg-options.
>>>
>>>	* doc/xml/manual/status_cxx2017.xml: Update status.
>>>	* include/c_global/cmath (hypot): Add three-dimensional overloads.
>>>	* testsuite/26_numerics/headers/cmath/hypot.cc: New.
>>>
>>>Tested powerpc64le-linux and x86_64-linux, committed to trunk.
>>
>>the new test currently FAILs on Solaris 12 (both SPARC and x86):
>>
>>+FAIL: 26_numerics/headers/cmath/hypot.cc (test for excess errors)
>>+WARNING: 26_numerics/headers/cmath/hypot.cc compilation failed to produce execu
>>table
>>
>>Excess errors:
>>/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/26_numerics/headers/cmath/hypot.cc:38: error: no matching function for call to 'hypot(double, double, double)'
>>/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/26_numerics/headers/cmath/hypot.cc:38: error: no matching function for call to 'hypot(double, double, double)'
>>/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/26_numerics/headers/cmath/hypot.cc:38: error: template argument 2 is invalid
>>
>>and many more.
>
>That would suggest Solaris uses include/c_std/cmath (where I forgot to
>add the new overloads) rather than include/c_global/cmath ... is that
>right?

Alternatively it's using c_global/cmath but _GLIBCXX_USE_C99_MATH_TR1
is not defined, as the new overloads are inside that block. I thought
that was defined for Solaris though, which is why we have the
__CORRECT_ISO_CPP11_MATH_H_PROTO there in that file.

Once again I wish we had a Solaris machine in the compile farm, or it
was possible to install a Solaris VM and get OS updates without paying
Oracle for the privilege.



More information about the Gcc-patches mailing list