https://gcc.gnu.org/g:c9a6c1b5a763d0d3f7a369ed281f9009f270939a

commit r16-1488-gc9a6c1b5a763d0d3f7a369ed281f9009f270939a
Author: Giuseppe D'Angelo <giuseppe.dang...@kdab.com>
Date:   Thu Jun 5 16:50:35 2025 +0200

    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>

Diff:
---
 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 98c2249039d1..3f4674d5ca42 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 7a7619e2628d..8cc7b11abd21 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 f32205d9c7f5..e94da9defb29 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>

Reply via email to