[patch] libstdc++/69893 make <tr1/cmath> work with C++11
Jonathan Wakely
jwakely@redhat.com
Tue Feb 23 19:49:00 GMT 2016
The <tr1/cmath> header was implicitly relying on the fact that the
additional overloads defined by C++11 were not added to the global
namespace, so that it could do "using ::acosh;" to get the C library's
acosh(double) declaration only, and not the C++11 overloads.
With the new <math.h> in GCC 6 that no longer works, because including
<math.h> before <tr1/cmath> means that "using ::acosh;" adds all the
C++11 overloads to namespace std::tr1, and then adding new overloads
with the same signatures is an error. (The same error can be triggered
in earlier versions of GCC with an explicit "using std::acosh;" at
global scope before including <tr1/cmath>).
The solution is to use the C++11 functions when possible, via "using
std::acosh;", and not add anything extra to namespace std::tr1. For
C++03 the additional overloads aren't in namespace std, so we continue
to define them explicitly in namespace std::tr1.
The new <math.h> also breaks the special handling for tr1::fabs,
because "using ::fabs;" might now bring in the unwanted std::fabs
overload for std::complex<>. The solution is similar to what is
already done for tr1::pow. I reworded the comment for tr1::pow,
because the problem being solved wasn't very clear to me at first
(even though I was already dealing with the same issue for fabs!)
Tested x86_64-linux, committed to trunk.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 12563 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20160223/ce2c44ce/attachment.bin>
More information about the Libstdc++
mailing list