aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-05-22 10:32:43 +0100
committerJonathan Wakely <jwakely@redhat.com>2024-05-28 10:19:44 +0100
commit89dff1488ef3fde11f6451e5f9817e14bcd6a873 (patch)
treed5adbfefedf5e67d2448dbf2ad3164b8100bc1ff /libstdc++-v3/include
parente78980fdd5e82e09e26f524e98ad9cd90a29c1c4 (diff)
downloadgcc-89dff1488ef3fde11f6451e5f9817e14bcd6a873.zip
gcc-89dff1488ef3fde11f6451e5f9817e14bcd6a873.tar.gz
gcc-89dff1488ef3fde11f6451e5f9817e14bcd6a873.tar.bz2
libstdc++: Guard use of sized deallocation [PR114940]
Clang does not enable -fsized-deallocation by default, which means it can't compile our <stacktrace> and <generator> headers. Make the __cpp_lib_generator macro depend on the compiler-defined __cpp_sized_deallocation macro, and change <stacktrace> to use unsized deallocation when __cpp_sized_deallocation isn't defined. libstdc++-v3/ChangeLog: PR libstdc++/114940 * include/bits/version.def (generator): Depend on __cpp_sized_deallocation. * include/bits/version.h: Regenerate. * include/std/stacktrace (_GLIBCXX_SIZED_DELETE): New macro. (basic_stacktrace::_Impl::_M_deallocate): Use it. (cherry picked from commit b2fdd508d7e63158e9d2a6dd04f901d02900def3)
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/bits/version.def2
-rw-r--r--libstdc++-v3/include/bits/version.h2
-rw-r--r--libstdc++-v3/include/std/stacktrace13
3 files changed, 13 insertions, 4 deletions
diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def
index 5c0477f..e5f4c4c 100644
--- a/libstdc++-v3/include/bits/version.def
+++ b/libstdc++-v3/include/bits/version.def
@@ -1642,7 +1642,7 @@ ftms = {
values = {
v = 202207;
cxxmin = 23;
- extra_cond = "__glibcxx_coroutine";
+ extra_cond = "__glibcxx_coroutine && __cpp_sized_deallocation";
};
};
diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h
index 65e708c..ad418d4 100644
--- a/libstdc++-v3/include/bits/version.h
+++ b/libstdc++-v3/include/bits/version.h
@@ -1824,7 +1824,7 @@
#undef __glibcxx_want_forward_like
#if !defined(__cpp_lib_generator)
-# if (__cplusplus >= 202100L) && (__glibcxx_coroutine)
+# if (__cplusplus >= 202100L) && (__glibcxx_coroutine && __cpp_sized_deallocation)
# define __glibcxx_generator 202207L
# if defined(__glibcxx_want_all) || defined(__glibcxx_want_generator)
# define __cpp_lib_generator 202207L
diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace
index d217d63..962dbed 100644
--- a/libstdc++-v3/include/std/stacktrace
+++ b/libstdc++-v3/include/std/stacktrace
@@ -553,6 +553,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
# define _GLIBCXX_OPERATOR_DELETE ::operator delete
#endif
+#if __cpp_sized_deallocation
+# define _GLIBCXX_SIZED_DELETE(T, p, n) \
+ _GLIBCXX_OPERATOR_DELETE((p), (n) * sizeof(T))
+#else
+# define _GLIBCXX_SIZED_DELETE(T, p, n) _GLIBCXX_OPERATOR_DELETE(p)
+#endif
+
// Precondition: _M_frames == nullptr && __n != 0
pointer
_M_allocate(allocator_type& __alloc, size_type __n) noexcept
@@ -592,8 +599,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
if (_M_capacity)
{
if constexpr (is_same_v<allocator_type, allocator<value_type>>)
- _GLIBCXX_OPERATOR_DELETE (static_cast<void*>(_M_frames),
- _M_capacity * sizeof(value_type));
+ _GLIBCXX_SIZED_DELETE(value_type,
+ static_cast<void*>(_M_frames),
+ _M_capacity);
else
__alloc.deallocate(_M_frames, _M_capacity);
_M_frames = nullptr;
@@ -601,6 +609,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
}
+#undef _GLIBCXX_SIZED_DELETE
#undef _GLIBCXX_OPERATOR_DELETE
#undef _GLIBCXX_OPERATOR_NEW