diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2025-06-05 16:50:35 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2025-06-12 18:41:30 +0200 |
commit | c9a6c1b5a763d0d3f7a369ed281f9009f270939a (patch) | |
tree | 8ee46650156d31ceeba772db0e24a055b3adfcb9 | |
parent | 774ae8734f0e199a8c6d29dd8c186b893385470b (diff) | |
download | gcc-c9a6c1b5a763d0d3f7a369ed281f9009f270939a.zip gcc-c9a6c1b5a763d0d3f7a369ed281f9009f270939a.tar.gz gcc-c9a6c1b5a763d0d3f7a369ed281f9009f270939a.tar.bz2 |
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.dangelo@kdab.com>
-rw-r--r-- | libstdc++-v3/include/bits/stl_algo.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_tempbuf.h | 2 | ||||
-rw-r--r-- | 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 98c2249..3f4674d 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 7a7619e..8cc7b11 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 f32205d..e94da9d 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> |