Hi,

This is a super-minor fix regarding the usage of an unreserved identifier in some private API. The patch is also available on forge here:

https://forge.sourceware.org/gcc/gcc-TEST/pulls/53

I'm just a bit unsure about where/how to add an autotest for this, any feedback is welcome.

Thank you,
--
Giuseppe D'Angelo
From 662d3d0a2f12efd347dcc85335ecbfece5dcfff0 Mon Sep 17 00:00:00 2001
From: Giuseppe D'Angelo <giuseppe.dang...@kdab.com>
Date: Thu, 5 Jun 2025 16:50:35 +0200
Subject: [PATCH] libstdc++: do not use an unreserved name in _Temporary_buffer
 [PR119496]

As the PR observes, _Temporary_buffer was using an unreserved name for a
member function that can therefore clash with macros defined by the
user. Avoid that by renaming the member function.

	PR libstdc++/119496

libstdc++-v3/ChangeLog:

	* include/bits/stl_algo.h: Adjust calls to requested_size.
	* include/bits/stl_tempbuf.h (requested_size): Rename with
	an _M_ prefix.
	* testsuite/20_util/119496.cc: New test.

Signed-off-by: Giuseppe D'Angelo <giuseppe.dang...@kdab.com>
---
 libstdc++-v3/include/bits/stl_algo.h     | 4 ++--
 libstdc++-v3/include/bits/stl_tempbuf.h  | 2 +-
 libstdc++-v3/testsuite/20_util/119496.cc | 5 +++++
 3 files changed, 8 insertions(+), 3 deletions(-)
 create mode 100644 libstdc++-v3/testsuite/20_util/119496.cc

diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h
index 98c2249039d..3f4674d5ca4 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -2511,7 +2511,7 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
       // [first,middle) and [middle,last).
       _TmpBuf __buf(__first, std::min(__len1, __len2));
 
-      if (__builtin_expect(__buf.size() == __buf.requested_size(), true))
+      if (__builtin_expect(__buf.size() == __buf._M_requested_size(), true))
 	std::__merge_adaptive
 	  (__first, __middle, __last, __len1, __len2, __buf.begin(), __comp);
       else if (__builtin_expect(__buf.begin() == 0, false))
@@ -5024,7 +5024,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
       // so the buffer only needs to fit half the range at once.
       _TmpBuf __buf(__first, (__last - __first + 1) / 2);
 
-      if (__builtin_expect(__buf.requested_size() == __buf.size(), true))
+      if (__builtin_expect(__buf._M_requested_size() == __buf.size(), true))
 	std::__stable_sort_adaptive(__first,
 				    __first + _DistanceType(__buf.size()),
 				    __last, __buf.begin(), __comp);
diff --git a/libstdc++-v3/include/bits/stl_tempbuf.h b/libstdc++-v3/include/bits/stl_tempbuf.h
index 7a7619e2628..8cc7b11abd2 100644
--- a/libstdc++-v3/include/bits/stl_tempbuf.h
+++ b/libstdc++-v3/include/bits/stl_tempbuf.h
@@ -227,7 +227,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       /// Returns the size requested by the constructor; may be >size().
       size_type
-      requested_size() const
+      _M_requested_size() const
       { return _M_original_len; }
 
       /// As per Table mumble.
diff --git a/libstdc++-v3/testsuite/20_util/119496.cc b/libstdc++-v3/testsuite/20_util/119496.cc
new file mode 100644
index 00000000000..3811b257404
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/119496.cc
@@ -0,0 +1,5 @@
+// { dg-do compile }
+// PR libstdc++/119496
+
+#define requested_size 1
+#include <bits/stl_tempbuf.h>
-- 
2.34.1

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to