From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 8BD263858C2F; Wed, 28 Sep 2022 23:35:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8BD263858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664408143; bh=OcS9Ej84QjugoR7GWhoiLqf5+bRyprr8l52TNDvsogU=; h=From:To:Subject:Date:From; b=r7+fyKzYrZnYQYgRCCqX7jCinir1dZ3EdHk4BNxkY+YbOSX20/tT6bLsQNOhO77YR /QjaUoh5E5Nu0ytRh+H698M7ZkATjHuXp3MI9be2YqoJM+S5cGBoBLgESQ9PPVr21r NXrdwDxQBE8h5TydAXW9JqHlCBnf07JrxQGdM1g4= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-2923] libstdc++: Disable volatile-qualified std::bind for C++20 X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: fa9bda3ea4315a7285edbc99323e3fa7885cbbb8 X-Git-Newrev: d01f112de4a54db6d2abef836e6dff3a08167389 Message-Id: <20220928233543.8BD263858C2F@sourceware.org> Date: Wed, 28 Sep 2022 23:35:43 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d01f112de4a54db6d2abef836e6dff3a08167389 commit r13-2923-gd01f112de4a54db6d2abef836e6dff3a08167389 Author: Jonathan Wakely Date: Wed Sep 28 12:39:41 2022 +0100 libstdc++: Disable volatile-qualified std::bind for C++20 LWG 2487 added a precondition to std::bind for C++17, making volatile-qualified uses undefined. We still support it, but with a deprecated warning. P1065R2 made it explicitly ill-formed for C++20, so we should no longer accept it as deprecated. This implements that change. libstdc++-v3/ChangeLog: * doc/xml/manual/evolution.xml: Document std::bind API changes. * doc/xml/manual/intro.xml: Document LWG 2487 status. * doc/xml/manual/using.xml: Clarify default value of _GLIBCXX_USE_DEPRECATED. * doc/html/*: Regenerate. * include/std/functional (_Bind::operator()(Args&&...) volatile) (_Bind::operator()(Args&&...) const volatile) (_Bind_result::operator()(Args&&...) volatile) (_Bind_result::operator()(Args&&...) const volatile): Replace with deleted overload for C++20 and later. * testsuite/20_util/bind/cv_quals.cc: Check for deprecated warnings in C++17. * testsuite/20_util/bind/cv_quals_2.cc: Likewise, and check for ill-formed in C++20. Diff: --- libstdc++-v3/doc/html/index.html | 2 +- libstdc++-v3/doc/html/manual/api.html | 5 ++++ libstdc++-v3/doc/html/manual/appendix.html | 2 +- libstdc++-v3/doc/html/manual/appendix_porting.html | 2 +- libstdc++-v3/doc/html/manual/bugs.html | 6 ++++ libstdc++-v3/doc/html/manual/index.html | 2 +- libstdc++-v3/doc/html/manual/using_macros.html | 5 ++-- libstdc++-v3/doc/xml/manual/evolution.xml | 13 +++++++++ libstdc++-v3/doc/xml/manual/intro.xml | 9 ++++++ libstdc++-v3/doc/xml/manual/using.xml | 5 ++-- libstdc++-v3/include/std/functional | 32 ++++++++++++++++------ libstdc++-v3/testsuite/20_util/bind/cv_quals.cc | 25 +++++++++-------- libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc | 12 ++++---- 13 files changed, 87 insertions(+), 33 deletions(-) diff --git a/libstdc++-v3/doc/html/index.html b/libstdc++-v3/doc/html/index.html index 5cc9226f4a1..1e0cecbcc4f 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
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
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 bbda6f5acf3..604380e0136 100644 --- a/libstdc++-v3/doc/html/manual/api.html +++ b/libstdc++-v3/doc/html/manual/api.html @@ -316,6 +316,8 @@ now defaults to zero. has_trivial_default_constructor, has_trivial_copy_constructor and has_trivial_copy_assign removed. +

+Calling a std::bind result as volatile was deprecated for C++17.

Profile Mode was deprecated.

7.2

Library Fundamentals TS header <experimental/source_location> @@ -468,4 +470,7 @@ they both derive from std::__new_allocator instea noexcept(false) to allow thread cancellation exceptions to be thrown from pthread_cond_wait without aborting the process. +

12.3

+Calling a std::bind result as volatile is ill-formed for C++20 +and later.

\ 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 bd462e9dddd..c563372e441 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
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
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 3d7fb564f4b..55d3f2318dd 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
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
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/bugs.html b/libstdc++-v3/doc/html/manual/bugs.html index 384fe8d2c4e..8e0bc1f9801 100644 --- a/libstdc++-v3/doc/html/manual/bugs.html +++ b/libstdc++-v3/doc/html/manual/bugs.html @@ -524,6 +524,12 @@

Avoid using dynamic_cast when it would be ill-formed. +

2487: + bind() should be const-overloaded + not cv-overloaded + +

Deprecate volatile-qualified operator() + for C++17, make it ill-formed for C++20.

2499: operator>>(basic_istream&, CharT*) makes it hard to avoid buffer overflows diff --git a/libstdc++-v3/doc/html/manual/index.html b/libstdc++-v3/doc/html/manual/index.html index 7122ddeaabd..2949509bca3 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
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
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/using_macros.html b/libstdc++-v3/doc/html/manual/using_macros.html index 98230465bed..62c66b7de4c 100644 --- a/libstdc++-v3/doc/html/manual/using_macros.html +++ b/libstdc++-v3/doc/html/manual/using_macros.html @@ -43,7 +43,7 @@ Configure), with the various --enable/--disable choices being translated to #define/#undef). -

ABI means that changing from the default value may +

ABI-changing means that changing from the default value may mean changing the ABI of compiled code. In other words, these choices control code which has already been compiled (i.e., in a binary such as libstdc++.a/.so). If you explicitly #define or @@ -53,7 +53,8 @@ consistent linkage requires changing the config headers before building/installing the library.

_GLIBCXX_USE_DEPRECATED

- Defined by default. Not configurable. ABI-changing. Turning this off + Defined to the value 1 by default. + Not configurable. ABI-changing. Turning this off removes older ARM-style iostreams code, and other anachronisms from the API. This macro is dependent on the version of the standard being tracked, and as a result may give different results for diff --git a/libstdc++-v3/doc/xml/manual/evolution.xml b/libstdc++-v3/doc/xml/manual/evolution.xml index 4923e8c4783..82936189179 100644 --- a/libstdc++-v3/doc/xml/manual/evolution.xml +++ b/libstdc++-v3/doc/xml/manual/evolution.xml @@ -817,6 +817,10 @@ now defaults to zero. has_trivial_copy_assign removed. + +Calling a std::bind result as volatile was deprecated for C++17. + + Profile Mode was deprecated.

<constant>7.2</constant> @@ -1067,4 +1071,13 @@ the process.
+ +
<constant>12.3</constant> + +Calling a std::bind result as volatile is ill-formed for C++20 +and later. + + +
+ diff --git a/libstdc++-v3/doc/xml/manual/intro.xml b/libstdc++-v3/doc/xml/manual/intro.xml index d341c3efe6d..e3a03cf9d59 100644 --- a/libstdc++-v3/doc/xml/manual/intro.xml +++ b/libstdc++-v3/doc/xml/manual/intro.xml @@ -1163,6 +1163,15 @@ requirements of the license of GCC. ill-formed. + 2487: + bind() should be const-overloaded + not cv-overloaded + + + Deprecate volatile-qualified operator() + for C++17, make it ill-formed for C++20. + + 2499: operator>>(basic_istream&, CharT*) makes it hard to avoid buffer overflows diff --git a/libstdc++-v3/doc/xml/manual/using.xml b/libstdc++-v3/doc/xml/manual/using.xml index 0acdba6b3bd..9c444dd2997 100644 --- a/libstdc++-v3/doc/xml/manual/using.xml +++ b/libstdc++-v3/doc/xml/manual/using.xml @@ -1062,7 +1062,7 @@ g++ -Winvalid-pch -I. -include stdc++.h -H -g -O2 hello.cc -o test.exe #define/#undef). - ABI means that changing from the default value may + ABI-changing means that changing from the default value may mean changing the ABI of compiled code. In other words, these choices control code which has already been compiled (i.e., in a binary such as libstdc++.a/.so). If you explicitly #define or @@ -1077,7 +1077,8 @@ g++ -Winvalid-pch -I. -include stdc++.h -H -g -O2 hello.cc -o test.exe _GLIBCXX_USE_DEPRECATED - Defined by default. Not configurable. ABI-changing. Turning this off + Defined to the value 1 by default. + Not configurable. ABI-changing. Turning this off removes older ARM-style iostreams code, and other anachronisms from the API. This macro is dependent on the version of the standard being tracked, and as a result may give different results for diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index c4f75880fd8..5235ef20332 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -465,6 +465,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// @endcond +#if __cplusplus == 201703L && _GLIBCXX_USE_DEPRECATED +# define _GLIBCXX_VOLATILE_BIND +// _GLIBCXX_RESOLVE_LIB_DEFECTS +// 2487. bind() should be const-overloaded, not cv-overloaded +# define _GLIBCXX_DEPR_BIND \ + [[deprecated("std::bind does not support volatile in C++17")]] +#elif __cplusplus < 201703L +# define _GLIBCXX_VOLATILE_BIND +# define _GLIBCXX_DEPR_BIND +#endif + /// Type of the function object returned from bind(). template class _Bind; @@ -501,6 +512,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ); } +#ifdef _GLIBCXX_VOLATILE_BIND // Call as volatile template _Result @@ -522,6 +534,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Mu<_Bound_args>()(__volget<_Indexes>(_M_bound_args), __args)... ); } +#endif // volatile template using _Mu_type = decltype( @@ -585,12 +598,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Bound_indexes()); } -#if __cplusplus > 201402L -# define _GLIBCXX_DEPR_BIND \ - [[deprecated("std::bind does not support volatile in C++17")]] -#else -# define _GLIBCXX_DEPR_BIND -#endif +#ifdef _GLIBCXX_VOLATILE_BIND // Call as volatile template, add_volatile>> @@ -614,6 +622,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::forward_as_tuple(std::forward<_Args>(__args)...), _Bound_indexes()); } +#endif // volatile }; /// Type of the function object returned from bind(). @@ -649,9 +658,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION (std::get<_Indexes>(_M_bound_args), __args)...); } +#ifdef _GLIBCXX_VOLATILE_BIND // Call as volatile template - _GLIBCXX20_CONSTEXPR _Res __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) volatile { @@ -661,7 +670,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Call as const volatile template - _GLIBCXX20_CONSTEXPR _Res __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) const volatile @@ -669,6 +677,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return std::__invoke_r<_Res>(_M_f, _Mu<_Bound_args>() (__volget<_Indexes>(_M_bound_args), __args)...); } +#endif // volatile public: typedef _Result result_type; @@ -710,6 +719,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Bound_indexes()); } +#ifdef _GLIBCXX_VOLATILE_BIND // Call as volatile template _GLIBCXX_DEPR_BIND @@ -731,7 +741,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::forward_as_tuple(std::forward<_Args>(__args)...), _Bound_indexes()); } +#else + template + void operator()(_Args&&...) const volatile = delete; +#endif // volatile }; + +#undef _GLIBCXX_VOLATILE_BIND #undef _GLIBCXX_DEPR_BIND /** diff --git a/libstdc++-v3/testsuite/20_util/bind/cv_quals.cc b/libstdc++-v3/testsuite/20_util/bind/cv_quals.cc index 83312397a93..79e3e2fbdb4 100644 --- a/libstdc++-v3/testsuite/20_util/bind/cv_quals.cc +++ b/libstdc++-v3/testsuite/20_util/bind/cv_quals.cc @@ -17,6 +17,7 @@ // 20.7.11 Function template bind +// { dg-options "-Wdeprecated-declarations" } // { dg-do run { target c++11 } } #include @@ -48,12 +49,12 @@ void test01() const auto b1 = std::bind(X()); VERIFY( b1() == 1 ); -#if __cplusplus <= 201402L +#if __cplusplus <= 201703L volatile auto b2 = std::bind(X()); - VERIFY( b2() == 2 ); + VERIFY( b2() == 2 ); // { dg-warning "deprecated" "" { target c++17_only } } const volatile auto b3 = std::bind(X()); - VERIFY( b3() == 3 ); + VERIFY( b3() == 3 ); // { dg-warning "deprecated" "" { target c++17_only } } #endif } @@ -65,12 +66,12 @@ void test02() const auto b1 = std::bind(X()); VERIFY( b1() == 1 ); -#if __cplusplus <= 201402L +#if __cplusplus <= 201703L volatile auto b2 = std::bind(X()); - VERIFY( b2() == 2 ); + VERIFY( b2() == 2 ); // { dg-warning "deprecated" "" { target c++17_only } } const volatile auto b3 = std::bind(X()); - VERIFY( b3() == 3 ); + VERIFY( b3() == 3 ); // { dg-warning "deprecated" "" { target c++17_only } } #endif } @@ -82,12 +83,12 @@ void test03() const auto b1 = std::bind(X(), _1, 0, _2); VERIFY( b1(0, 0) == 1 ); -#if __cplusplus <= 201402L +#if __cplusplus <= 201703L volatile auto b2 = std::bind(X(), _1, _2, 0); - VERIFY( b2(0, 0) == 2 ); + VERIFY( b2(0, 0) == 2 ); // { dg-warning "deprecated" "" { target c++17_only } } const volatile auto b3 = std::bind(X(), _1, 0, _2); - VERIFY( b3(0, 0) == 3 ); + VERIFY( b3(0, 0) == 3 ); // { dg-warning "deprecated" "" { target c++17_only } } #endif } @@ -99,12 +100,12 @@ void test04() const auto b1 = std::bind(X(), _1, 0, _2); VERIFY( b1(0, 0) == 1 ); -#if __cplusplus <= 201402L +#if __cplusplus <= 201703L volatile auto b2 = std::bind(X(), _1, _2, 0); - VERIFY( b2(0, 0) == 2 ); + VERIFY( b2(0, 0) == 2 ); // { dg-warning "deprecated" "" { target c++17_only } } const volatile auto b3 = std::bind(X(), _1, 0, _2); - VERIFY( b3(0, 0) == 3 ); + VERIFY( b3(0, 0) == 3 ); // { dg-warning "deprecated" "" { target c++17_only } } #endif } diff --git a/libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc b/libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc index 7a85568c66a..d2ebad72fdf 100644 --- a/libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc +++ b/libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc @@ -15,7 +15,9 @@ // with this library; see the file COPYING3. If not see // . -// { dg-do run { target c++11 } } +// { dg-options "-Wdeprecated-declarations" } +// { dg-do run { target { c++11 && c++17_down } } } +// { dg-do compile { target c++20 } } #include #include @@ -33,13 +35,13 @@ void test01() const auto b0 = std::bind(X()); VERIFY( b0() == 0 ); -#if __cplusplus <= 201402L volatile auto b1 = std::bind(X()); - VERIFY( b1() == 1 ); + VERIFY( b1() == 1 ); // { dg-warning "deprecated" "" { target c++17_only } } + // { dg-error "no match" "" { target c++20 } 39 } const volatile auto b2 = std::bind(X()); - VERIFY( b2() == 2 ); -#endif + VERIFY( b2() == 2 ); // { dg-warning "deprecated" "" { target c++17_only } } + // { dg-error "no match" "" { target c++20 } 43 } } int main()