]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: do not use an unreserved name in _Temporary_buffer [PR119496]
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Thu, 5 Jun 2025 14:50:35 +0000 (16:50 +0200)
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Thu, 12 Jun 2025 16:41:30 +0000 (18:41 +0200)
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.dangelo@kdab.com>
libstdc++-v3/include/bits/stl_algo.h
libstdc++-v3/include/bits/stl_tempbuf.h
libstdc++-v3/testsuite/17_intro/names.cc

index 98c2249039d1a75919e98ee915b92b2cea6390aa..3f4674d5ca420cac9d8b27f1bfe2697ef8c7162c 100644 (file)
@@ -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);
index 7a7619e2628d2d942cc614dfd2274350abb9ccb2..8cc7b11abd2174998496c8323c25c6d38fd7b673 100644 (file)
@@ -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.
index f32205d9c7f522ec8e04a295972a1ca845558b14..e94da9defb29fad8467203fe181f150a6c08a904 100644 (file)
 # endif
 #endif
 
+// PR libstdc++/119496
+// _Temporary_buffer used to have a member with this name
+#define requested_size 1
+
 #include <bits/stdc++.h>