From: Jonathan Wakely Date: Mon, 12 May 2025 10:34:01 +0000 (+0100) Subject: libstdc++: Deprecate non-standard std::fabs(const complex&) [PR120235] X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6dbcbd96e90159e87a339b98192b7e6e5534b0d7;p=thirdparty%2Fgcc.git libstdc++: Deprecate non-standard std::fabs(const complex&) [PR120235] There was an overload of fabs for std::complex in TR1 and in some C++0x drafts, but it was removed from the working draft by LWG 595. Since we've been providing it for decades we should deprecate it before removing it. libstdc++-v3/ChangeLog: PR libstdc++/120235 * doc/html/*: Regenerate. * doc/xml/manual/evolution.xml: Document deprecation. * include/std/complex: Replace references to TR1 subclauses with corresponding C++11 subclauses. (fabs): Add deprecated attribute. * testsuite/26_numerics/complex/fabs_neg.cc: New test. Reviewed-by: Tomasz Kamiński --- diff --git a/libstdc++-v3/doc/html/index.html b/libstdc++-v3/doc/html/index.html index d465fb6c7f5..dd31cff3181 100644 --- a/libstdc++-v3/doc/html/index.html +++ b/libstdc++-v3/doc/html/index.html @@ -142,7 +142,7 @@ Existing tests
C++11 Requirements Test Sequence Descriptions -
ABI Policy and Guidelines
The C++ Interface
Versioning
Goals
History
Prerequisites
Configuring
Checking Active
Allowed Changes
Prohibited Changes
Implementation
Testing
Single ABI Testing
Multiple ABI Testing
Outstanding Issues
API Evolution and Deprecation History
3.0
3.1
3.2
3.3
3.4
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5
5.3
6
7
7.2
7.3
8
9
10
11
12
12.3
13
13.3
14
15
Backwards Compatibility
First
Second
Third
Pre-ISO headers removed
Extension headers hash_map, hash_set moved to ext or backwards
No ios::nocreate/ios::noreplace. +
ABI Policy and Guidelines
The C++ Interface
Versioning
Goals
History
Prerequisites
Configuring
Checking Active
Allowed Changes
Prohibited Changes
Implementation
Testing
Single ABI Testing
Multiple ABI Testing
Outstanding Issues
API Evolution and Deprecation History
3.0
3.1
3.2
3.3
3.4
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5
5.3
6
7
7.2
7.3
8
9
10
11
12
12.3
13
13.3
14
15
16
Backwards Compatibility
First
Second
Third
Pre-ISO headers removed
Extension headers hash_map, hash_set moved to ext or backwards
No ios::nocreate/ios::noreplace.
No stream::attach(int fd)
diff --git a/libstdc++-v3/doc/html/manual/api.html b/libstdc++-v3/doc/html/manual/api.html index 09afdb3e703..4441d9cdbae 100644 --- a/libstdc++-v3/doc/html/manual/api.html +++ b/libstdc++-v3/doc/html/manual/api.html @@ -490,7 +490,7 @@ to provide the symbols for the experimental C++ Contracts support.

<stacktrace> header were added to the static library libstdc++exp.a.

14

-Deprecate the non-standard overload that allows std::setfill +Deprecated the non-standard overload that allows std::setfill to be used with std::basic_istream.

The extension allowing std::basic_string to be instantiated @@ -509,4 +509,7 @@ and removed in C++20:

Nested result_type and argument_type removed from std::hash specializations for C++20. +

16

+Deprecated the non-standard overload of std::fabs for +std::complex arguments.

\ No newline at end of file diff --git a/libstdc++-v3/doc/html/manual/appendix.html b/libstdc++-v3/doc/html/manual/appendix.html index 69a0e0018f3..e71ea5423a0 100644 --- a/libstdc++-v3/doc/html/manual/appendix.html +++ b/libstdc++-v3/doc/html/manual/appendix.html @@ -16,7 +16,7 @@ Existing tests
C++11 Requirements Test Sequence Descriptions -
ABI Policy and Guidelines
The C++ Interface
Versioning
Goals
History
Prerequisites
Configuring
Checking Active
Allowed Changes
Prohibited Changes
Implementation
Testing
Single ABI Testing
Multiple ABI Testing
Outstanding Issues
API Evolution and Deprecation History
3.0
3.1
3.2
3.3
3.4
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5
5.3
6
7
7.2
7.3
8
9
10
11
12
12.3
13
13.3
14
15
Backwards Compatibility
First
Second
Third
Pre-ISO headers removed
Extension headers hash_map, hash_set moved to ext or backwards
No ios::nocreate/ios::noreplace. +
ABI Policy and Guidelines
The C++ Interface
Versioning
Goals
History
Prerequisites
Configuring
Checking Active
Allowed Changes
Prohibited Changes
Implementation
Testing
Single ABI Testing
Multiple ABI Testing
Outstanding Issues
API Evolution and Deprecation History
3.0
3.1
3.2
3.3
3.4
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5
5.3
6
7
7.2
7.3
8
9
10
11
12
12.3
13
13.3
14
15
16
Backwards Compatibility
First
Second
Third
Pre-ISO headers removed
Extension headers hash_map, hash_set moved to ext or backwards
No ios::nocreate/ios::noreplace.
No stream::attach(int fd)
diff --git a/libstdc++-v3/doc/html/manual/appendix_porting.html b/libstdc++-v3/doc/html/manual/appendix_porting.html index c76ef295e78..e0f52dba6d2 100644 --- a/libstdc++-v3/doc/html/manual/appendix_porting.html +++ b/libstdc++-v3/doc/html/manual/appendix_porting.html @@ -14,7 +14,7 @@ Existing tests
C++11 Requirements Test Sequence Descriptions -
ABI Policy and Guidelines
The C++ Interface
Versioning
Goals
History
Prerequisites
Configuring
Checking Active
Allowed Changes
Prohibited Changes
Implementation
Testing
Single ABI Testing
Multiple ABI Testing
Outstanding Issues
API Evolution and Deprecation History
3.0
3.1
3.2
3.3
3.4
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5
5.3
6
7
7.2
7.3
8
9
10
11
12
12.3
13
13.3
14
15
Backwards Compatibility
First
Second
Third
Pre-ISO headers removed
Extension headers hash_map, hash_set moved to ext or backwards
No ios::nocreate/ios::noreplace. +
ABI Policy and Guidelines
The C++ Interface
Versioning
Goals
History
Prerequisites
Configuring
Checking Active
Allowed Changes
Prohibited Changes
Implementation
Testing
Single ABI Testing
Multiple ABI Testing
Outstanding Issues
API Evolution and Deprecation History
3.0
3.1
3.2
3.3
3.4
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5
5.3
6
7
7.2
7.3
8
9
10
11
12
12.3
13
13.3
14
15
16
Backwards Compatibility
First
Second
Third
Pre-ISO headers removed
Extension headers hash_map, hash_set moved to ext or backwards
No ios::nocreate/ios::noreplace.
No stream::attach(int fd)
diff --git a/libstdc++-v3/doc/html/manual/index.html b/libstdc++-v3/doc/html/manual/index.html index a7af1785c5d..5f910927672 100644 --- a/libstdc++-v3/doc/html/manual/index.html +++ b/libstdc++-v3/doc/html/manual/index.html @@ -123,7 +123,7 @@ Existing tests
C++11 Requirements Test Sequence Descriptions -
ABI Policy and Guidelines
The C++ Interface
Versioning
Goals
History
Prerequisites
Configuring
Checking Active
Allowed Changes
Prohibited Changes
Implementation
Testing
Single ABI Testing
Multiple ABI Testing
Outstanding Issues
API Evolution and Deprecation History
3.0
3.1
3.2
3.3
3.4
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5
5.3
6
7
7.2
7.3
8
9
10
11
12
12.3
13
13.3
14
15
Backwards Compatibility
First
Second
Third
Pre-ISO headers removed
Extension headers hash_map, hash_set moved to ext or backwards
No ios::nocreate/ios::noreplace. +
ABI Policy and Guidelines
The C++ Interface
Versioning
Goals
History
Prerequisites
Configuring
Checking Active
Allowed Changes
Prohibited Changes
Implementation
Testing
Single ABI Testing
Multiple ABI Testing
Outstanding Issues
API Evolution and Deprecation History
3.0
3.1
3.2
3.3
3.4
4.0
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5
5.3
6
7
7.2
7.3
8
9
10
11
12
12.3
13
13.3
14
15
16
Backwards Compatibility
First
Second
Third
Pre-ISO headers removed
Extension headers hash_map, hash_set moved to ext or backwards
No ios::nocreate/ios::noreplace.
No stream::attach(int fd)
diff --git a/libstdc++-v3/doc/xml/manual/evolution.xml b/libstdc++-v3/doc/xml/manual/evolution.xml index 814473f87bd..73b9f17f3a3 100644 --- a/libstdc++-v3/doc/xml/manual/evolution.xml +++ b/libstdc++-v3/doc/xml/manual/evolution.xml @@ -1117,7 +1117,7 @@ header were added to the static library libstdc++exp.a.
<constant>14</constant> -Deprecate the non-standard overload that allows std::setfill +Deprecated the non-standard overload that allows std::setfill to be used with std::basic_istream. @@ -1152,4 +1152,11 @@ Nested result_type and argument_type removed from
+
<constant>16</constant> + +Deprecated the non-standard overload of std::fabs for +std::complex arguments. + +
+ diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index 59ef9057c41..67f37d4ec2b 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -969,7 +969,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif - // 26.2.7/4: arg(__z): Returns the phase angle of __z. + // C++11 26.4.7 [complex.value.ops]/4: arg(z): Returns the phase angle of z. template inline _Tp __complex_arg(const complex<_Tp>& __z) @@ -2123,8 +2123,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template std::complex<_Tp> acosh(const std::complex<_Tp>&); template std::complex<_Tp> asinh(const std::complex<_Tp>&); template std::complex<_Tp> atanh(const std::complex<_Tp>&); - // DR 595. - template _Tp fabs(const std::complex<_Tp>&); template inline std::complex<_Tp> @@ -2309,7 +2307,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION acos(const std::complex<_Tp>& __z) { return __complex_acos(__z.__rep()); } #else - /// acos(__z) [8.1.2]. + /// acos(__z) C++11 26.4.8 [complex.transcendentals] // Effects: Behaves the same as C99 function cacos, defined // in subclause 7.3.5.1. template @@ -2345,7 +2343,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION asin(const std::complex<_Tp>& __z) { return __complex_asin(__z.__rep()); } #else - /// asin(__z) [8.1.3]. + /// asin(__z) C++11 26.4.8 [complex.transcendentals] // Effects: Behaves the same as C99 function casin, defined // in subclause 7.3.5.2. template @@ -2389,7 +2387,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION atan(const std::complex<_Tp>& __z) { return __complex_atan(__z.__rep()); } #else - /// atan(__z) [8.1.4]. + /// atan(__z) C++11 26.4.8 [complex.transcendentals] // Effects: Behaves the same as C99 function catan, defined // in subclause 7.3.5.3. template @@ -2425,7 +2423,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION acosh(const std::complex<_Tp>& __z) { return __complex_acosh(__z.__rep()); } #else - /// acosh(__z) [8.1.5]. + /// acosh(__z) C++11 26.4.8 [complex.transcendentals] // Effects: Behaves the same as C99 function cacosh, defined // in subclause 7.3.6.1. template @@ -2464,7 +2462,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION asinh(const std::complex<_Tp>& __z) { return __complex_asinh(__z.__rep()); } #else - /// asinh(__z) [8.1.6]. + /// asinh(__z) C++11 26.4.8 [complex.transcendentals] // Effects: Behaves the same as C99 function casin, defined // in subclause 7.3.6.2. template @@ -2508,7 +2506,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION atanh(const std::complex<_Tp>& __z) { return __complex_atanh(__z.__rep()); } #else - /// atanh(__z) [8.1.7]. + /// atanh(__z) C++11 26.4.8 [complex.transcendentals] // Effects: Behaves the same as C99 function catanh, defined // in subclause 7.3.6.3. template @@ -2518,14 +2516,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif template + _GLIBCXX11_DEPRECATED_SUGGEST("std::abs") inline _Tp - /// fabs(__z) [8.1.8]. + /// fabs(__z) TR1 8.1.8 [tr.c99.cmplx.fabs] // Effects: Behaves the same as C99 function cabs, defined // in subclause 7.3.8.1. fabs(const std::complex<_Tp>& __z) { return std::abs(__z); } - /// Additional overloads [8.1.9]. + // Additional overloads C++11 26.4.9 [cmplx.over] + template inline typename __gnu_cxx::__promote<_Tp>::__type arg(_Tp __x) diff --git a/libstdc++-v3/testsuite/26_numerics/complex/fabs_neg.cc b/libstdc++-v3/testsuite/26_numerics/complex/fabs_neg.cc new file mode 100644 index 00000000000..36c483e900c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/fabs_neg.cc @@ -0,0 +1,13 @@ +// { dg-do compile } +// Bug 120235 std::fabs(const std::complex&) should not be defined + +#include + +void test_pr120235(std::complex c) +{ + (void) std::fabs(c); + // { dg-error "no matching function" "" { target c++98_only } 8 } + // { dg-warning "deprecated: use 'std::abs'" "" { target c++11 } 8 } +} + +// { dg-prune-output "no type named '__type'" }