[PATCH] PR libstdc++/61761 fix std::proj for targets without C99 cproj
Jonathan Wakely
jwakely@redhat.com
Fri May 3 12:09:00 GMT 2019
On 03/05/19 11:21 +0000, Szabolcs Nagy wrote:
>On 03/05/2019 12:16, Jonathan Wakely wrote:
>> On 03/05/19 09:23 +0000, Szabolcs Nagy wrote:
>>> On 01/05/2019 01:09, Jonathan Wakely wrote:
>>>> The current generic implementation of __complex_proj used when cproj is
>>>> not available calculates the wrong projection, giving a different result
>>>> than given by C99's cproj.
>>>>
>>>> When C99 cproj is not available but isinf and copysign are, use those to
>>>> give correct results for float, double and long double. Otherwise, and
>>>> for other specializations of std::complex, just use a generic version
>>>> that returns its argument, and so doesn't support infinities.
>>>>
>>>> We might want to consider adding additional overloads of __complex_proj
>>>> to support extended types such as _Float64x, _Float128 etc.
>>>>
>>>> Â Â Â Â PR libstdc++/61761
>>>> Â Â Â Â * include/std/complex (__complex_proj): Return parameter unchanged.
>>>> Â Â Â Â [_GLIBCXX_USE_C99_COMPLEX] (__complex_proj): Change overloads for
>>>> Â Â Â Â floating-point types to take std::complex arguments.
>>>> Â Â Â Â [_GLIBCXX_USE_C99_MATH_TR1] (__complex_proj): Add overloads for
>>>> Â Â Â Â floating-point types.
>>>> Â Â Â Â * testsuite/26_numerics/complex/proj.cc: New test.
>>>>
>>>> Tested powerpc64le-linux, powerpc-aix7.2.0.0, x86_64-freebsd11.2,
>>>> committed to trunk.
>>>
>>> fails on aarch64-none-elf (newlib) with
>>>
>>> FAIL: 26_numerics/complex/proj.cc (test for excess errors)
>>> Excess errors:
>>> /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:32: error: 'copysign' is not a member of 'std'; did you mean 'copy_n'?
>>> /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:32: error: 'copysign' is not a member of 'std'; did you mean 'copy_n'?
>>> /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:34: error: 'copysign' is not a member of 'std'; did you mean 'copy_n'?
>>> /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:34: error: 'copysign' is not a member of 'std'; did you mean 'copy_n'?
>>>
>>> i assume std::copysign should be visible in <complex> via <cmath>
>>
>> It should, but only for C++11, and this needs to work for C++98 too. I
>> missed that problem.
>>
>>> but cmath does not have it.
>>
>> Hmm, which file in the source tree does the include/cmath symlink in
>> the build tree point to?
>
>/work/b/build-aarch64-none-elf/obj/gcc2/aarch64-none-elf/libstdc++-v3$ ls -l include/cmath
>lrwxrwxrwx 1 szabolcs szabolcs 51 May 1 18:06 include/cmath -> /work/b/src/gcc/libstdc++-v3/include/c_global/cmath
Oh, I see the problem. <complex> and <cmath> both guard use of
copysign by _GLIBCXX_USE_C99_MATH_TR1 but the test just uses it
unconditionally.
Does the attached patch work?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 1308 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20190503/f3719f3d/attachment.bin>
More information about the Libstdc++
mailing list