Hi,

On 05/06/2025 23:22, Giuseppe D'Angelo wrote:
Thanks for the quick review! I've pushed a new version on Forge.

Patch was iterated upon on Forge and approved there.
Committed as r16-1488-gc9a6c1b5a763d0 and attached.

Cheers,
--
Giuseppe D'Angelo
From c9a6c1b5a763d0d3f7a369ed281f9009f270939a 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/17_intro/names.cc: Add a #define for
	requested_size.

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/17_intro/names.cc | 4 ++++
 3 files changed, 7 insertions(+), 3 deletions(-)

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/17_intro/names.cc b/libstdc++-v3/testsuite/17_intro/names.cc
index f32205d9c7f..e94da9defb2 100644
--- a/libstdc++-v3/testsuite/17_intro/names.cc
+++ b/libstdc++-v3/testsuite/17_intro/names.cc
@@ -404,4 +404,8 @@
 # endif
 #endif
 
+// PR libstdc++/119496
+// _Temporary_buffer used to have a member with this name
+#define requested_size 1
+
 #include <bits/stdc++.h>
-- 
2.43.0

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

Reply via email to