[committed v2] libstdc++: Deprecate __gnu_pbds extensions [PR127690]

Jonathan Wakely jwakely@redhat.com
Thu Dec 3 21:54:08 GMT 2026


These extensions are unmaintained and causing a maintenance burden that
is disproportionate to their usefulness.

libstdc++-v3/ChangeLog:

	PR libstdc++/127690
	* doc/xml/manual/evolution.xml: Document pbds deprecation.
	* doc/xml/manual/policy_data_structures.xml: Document status
	and deprecation.
	* doc/html/manual/*: Regenerate.
	* include/ext/pb_ds/tag_and_trait.hpp: Add #warning and
	@deprecated comment.
	* scripts/testsuite_flags.in: Add macro to suppress new warning.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
---

Tested x86_64-linux.

v2 is the same as v1 with a new paragraph added to
doc/xml/manual/policy_data_structures.xml explaining the deprecation.

Pushed to trunk.

 libstdc++-v3/doc/html/manual/api.html                  |  3 +++
 .../doc/html/manual/policy_data_structures.html        | 10 +++++++++-
 libstdc++-v3/doc/xml/manual/evolution.xml              |  5 +++++
 libstdc++-v3/doc/xml/manual/policy_data_structures.xml | 10 +++++++++-
 libstdc++-v3/include/ext/pb_ds/tag_and_trait.hpp       |  9 ++++++++-
 libstdc++-v3/scripts/testsuite_flags.in                |  3 ++-
 6 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/doc/html/manual/api.html b/libstdc++-v3/doc/html/manual/api.html
index da86978b379c..60c87722ac5f 100644
--- a/libstdc++-v3/doc/html/manual/api.html
+++ b/libstdc++-v3/doc/html/manual/api.html
@@ -524,4 +524,7 @@ construction from <code class="classname">std::promise</code> and
 <code class="code">std::numeric_limits::has_denorm_loss</code>,
 and <code class="code">enum std::float_denorm_style</code> and its enumerators
 were deprecated for C++23.
+</p><p>
+Policy-based data structures in namespace <code class="code">__gnu_pbds</code>
+were deprecated.
 </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="abi.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="appendix_porting.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="backwards.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ABI Policy and Guidelines </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Backwards Compatibility</td></tr></table></div></body></html>
\ No newline at end of file
diff --git a/libstdc++-v3/doc/html/manual/policy_data_structures.html b/libstdc++-v3/doc/html/manual/policy_data_structures.html
index 8f772fa536ee..78c3f0d8645a 100644
--- a/libstdc++-v3/doc/html/manual/policy_data_structures.html
+++ b/libstdc++-v3/doc/html/manual/policy_data_structures.html
@@ -68,10 +68,18 @@
       This is a library of policy-based elementary data structures:
       associative containers and priority queues. It is designed for
       high-performance, flexibility, semantic safety, and conformance to
-      the corresponding containers in <code class="literal">std</code> and
+      the corresponding C++98 containers in <code class="literal">std</code> and
       <code class="literal">std::tr1</code> (except for some points where it differs
       by design).
     </p><p>
+      These extensions have not been updated or maintained for many years,
+      so only support the interfaces of C++98 containers. In particular,
+      they do not support move semantics, initializer-list constructors,
+      allocator propagation, or scoped allocators.
+      <span class="bold"><strong>
+	These data structures are deprecated and will be removed in
+	a future version of GCC.
+      </strong></span>
     </p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="pbds.intro.issues"></a>Performance Issues</h3></div></div></div><p>
       </p><p>
 	An attempt is made to categorize the wide variety of possible
diff --git a/libstdc++-v3/doc/xml/manual/evolution.xml b/libstdc++-v3/doc/xml/manual/evolution.xml
index f934504ce881..a864bdd1b925 100644
--- a/libstdc++-v3/doc/xml/manual/evolution.xml
+++ b/libstdc++-v3/doc/xml/manual/evolution.xml
@@ -1178,6 +1178,11 @@ and <code>enum std::float_denorm_style</code> and its enumerators
 were deprecated for C++23.
 </para>
 
+<para>
+Policy-based data structures in namespace <code>__gnu_pbds</code>
+were deprecated.
+</para>
+
 </section>
 
 </section>
diff --git a/libstdc++-v3/doc/xml/manual/policy_data_structures.xml b/libstdc++-v3/doc/xml/manual/policy_data_structures.xml
index 276fe7e7a892..7dab783e5749 100644
--- a/libstdc++-v3/doc/xml/manual/policy_data_structures.xml
+++ b/libstdc++-v3/doc/xml/manual/policy_data_structures.xml
@@ -28,11 +28,19 @@
       This is a library of policy-based elementary data structures:
       associative containers and priority queues. It is designed for
       high-performance, flexibility, semantic safety, and conformance to
-      the corresponding containers in <literal>std</literal> and
+      the corresponding C++98 containers in <literal>std</literal> and
       <literal>std::tr1</literal> (except for some points where it differs
       by design).
     </para>
     <para>
+      These extensions have not been updated or maintained for many years,
+      so only support the interfaces of C++98 containers. In particular,
+      they do not support move semantics, initializer-list constructors,
+      allocator propagation, or scoped allocators.
+      <emphasis role="bold">
+	These data structures are deprecated and will be removed in
+	a future version of GCC.
+      </emphasis>
     </para>
 
     <section xml:id="pbds.intro.issues">
diff --git a/libstdc++-v3/include/ext/pb_ds/tag_and_trait.hpp b/libstdc++-v3/include/ext/pb_ds/tag_and_trait.hpp
index bdfb9cd93b5e..292f480cf0a7 100644
--- a/libstdc++-v3/include/ext/pb_ds/tag_and_trait.hpp
+++ b/libstdc++-v3/include/ext/pb_ds/tag_and_trait.hpp
@@ -45,6 +45,11 @@
 #include <bits/c++config.h>
 #include <ext/pb_ds/detail/type_utils.hpp>
 
+#if defined(__DEPRECATED) && !defined(_GLIBCXX_PBDS_NO_DEPRECATION_WARNING)
+# warning "libstdc++ __gnu_pbds extensions are deprecated"
+# warning "define _GLIBCXX_PBDS_NO_DEPRECATION_WARNING to silence this"
+#endif
+
 /**
  * @namespace __gnu_pbds
  * @brief GNU extensions for policy-based data structures for public use.
@@ -63,12 +68,14 @@ namespace __gnu_pbds
    *  For details, see:
    *  http://gcc.gnu.org/onlinedocs/libstdc++/ext/pb_ds/index.html
    *
+   *  @deprecated The policy-based data structures will be removed from GCC.
+   *
    *  @{
    */
 
   /**
    *  @defgroup tags Tags
-   *  @{   
+   *  @{
    */
   /// A trivial iterator tag. Signifies that the iterators has none of
   /// std::iterators's movement abilities.
diff --git a/libstdc++-v3/scripts/testsuite_flags.in b/libstdc++-v3/scripts/testsuite_flags.in
index 8bf4918287ad..dc85e45e6eab 100755
--- a/libstdc++-v3/scripts/testsuite_flags.in
+++ b/libstdc++-v3/scripts/testsuite_flags.in
@@ -58,7 +58,8 @@ case ${query} in
     --cxxflags)
       CXXFLAGS_default="-fmessage-length=0 -fno-show-column"
       CXXFLAGS_config="@SECTION_FLAGS@ @EXTRA_CXX_FLAGS@"
-      echo ${CXXFLAGS_default} ${CXXFLAGS_config} 
+      CXXFLAGS_pbds="-D_GLIBCXX_PBDS_NO_DEPRECATION_WARNING"
+      echo ${CXXFLAGS_default} ${CXXFLAGS_config} ${CXXFLAGS_pbds}
       ;;
     --cxxvtvflags)
       CXXFLAGS_vtv="@VTV_CXXFLAGS@"
-- 
2.56.1



More information about the Libstdc++ mailing list