[libcxx-commits] [libcxx] [libc++] Remove <cstdlib> include from <exception> (PR #166340)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Nov 4 01:17:51 PST 2025
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/166340
None
>From a76ed12ec01dfdac2a1fa5cdf20f6db579c470b9 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Tue, 4 Nov 2025 10:17:32 +0100
Subject: [PATCH] [libc++] Remove <cstdlib> include from <exception>
---
libcxx/include/__exception/exception_ptr.h | 4 ++--
libcxx/include/exception | 4 ++++
libcxx/test/libcxx/transitive_includes/cxx26.csv | 1 -
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index e78126ea23852..fc8da52aeae96 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__cstddef/nullptr_t.h>
+#include <__cstddef/size_t.h>
#include <__exception/operations.h>
#include <__memory/addressof.h>
#include <__memory/construct_at.h>
@@ -18,7 +19,6 @@
#include <__type_traits/is_pointer.h>
#include <__utility/move.h>
#include <__utility/swap.h>
-#include <cstdlib>
#include <typeinfo>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -35,7 +35,7 @@ _LIBCPP_PUSH_MACROS
namespace __cxxabiv1 {
extern "C" {
-_LIBCPP_OVERRIDABLE_FUNC_VIS void* __cxa_allocate_exception(size_t) throw();
+_LIBCPP_OVERRIDABLE_FUNC_VIS void* __cxa_allocate_exception(std::size_t) throw();
_LIBCPP_OVERRIDABLE_FUNC_VIS void __cxa_free_exception(void*) throw();
struct __cxa_exception;
diff --git a/libcxx/include/exception b/libcxx/include/exception
index 74229cd16c006..78b54f3931c1e 100644
--- a/libcxx/include/exception
+++ b/libcxx/include/exception
@@ -97,6 +97,10 @@ template <class E> void rethrow_if_nested(const E& e);
# include <new>
# include <type_traits>
# endif
+
+# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
+# include <cstdlib>
+# endif
#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
#endif // _LIBCPP_EXCEPTION
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index d047b29b63cc6..8c3e1f0a97dfe 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -245,7 +245,6 @@ deque stdexcept
deque tuple
deque version
exception cstdint
-exception cstdlib
exception typeinfo
exception version
execution version
More information about the libcxx-commits
mailing list