Skip to content

[libc++] Remove <stddef.h> includes from the granularized <cstddef> headers #114788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions libcxx/include/__cstddef/nullptr_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
#define _LIBCPP___CSTDDEF_NULLPTR_T_H

#include <__config>
#include <stddef.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

using ::nullptr_t;
using nullptr_t = decltype(nullptr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The big difference is that if the system headers and the compiler disagree about what those types should be, we'll now favour the compiler's definitions whereas we would have previously favoured the system headers (or the Clang builtin headers, depending on which one comes first).

I can't imagine why it would make sense for the compiler and the system library to disagree, but I'm fairly certain there are setups in which they disagree (those setups are probably brittle to the point of being arguably wrong).

So TLDR, it's probably possible for this patch to introduce a behavior change in some weird setups, but I don't think that's something we should take into account beyond recognizing that possibility.


_LIBCPP_END_NAMESPACE_STD

Expand Down
3 changes: 1 addition & 2 deletions libcxx/include/__cstddef/ptrdiff_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
#define _LIBCPP___CSTDDEF_PTRDIFF_T_H

#include <__config>
#include <stddef.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS;
using ptrdiff_t = decltype(static_cast<int*>(nullptr) - static_cast<int*>(nullptr));

_LIBCPP_END_NAMESPACE_STD

Expand Down
3 changes: 1 addition & 2 deletions libcxx/include/__cstddef/size_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
#define _LIBCPP___CSTDDEF_SIZE_T_H

#include <__config>
#include <stddef.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

using ::size_t _LIBCPP_USING_IF_EXISTS;
using size_t = decltype(sizeof(int));

_LIBCPP_END_NAMESPACE_STD

Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__exception/exception_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define _LIBCPP___EXCEPTION_EXCEPTION_PTR_H

#include <__config>
#include <__cstddef/nullptr_t.h>
#include <__exception/operations.h>
#include <__memory/addressof.h>
#include <__memory/construct_at.h>
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__functional/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <__assert>
#include <__config>
#include <__cstddef/nullptr_t.h>
#include <__exception/exception.h>
#include <__functional/binary_function.h>
#include <__functional/invoke.h>
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__functional/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define _LIBCPP___FUNCTIONAL_HASH_H

#include <__config>
#include <__cstddef/nullptr_t.h>
#include <__functional/unary_function.h>
#include <__fwd/functional.h>
#include <__type_traits/conjunction.h>
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__memory/shared_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <__compare/compare_three_way.h>
#include <__compare/ordering.h>
#include <__config>
#include <__cstddef/nullptr_t.h>
#include <__cstddef/ptrdiff_t.h>
#include <__exception/exception.h>
#include <__functional/binary_function.h>
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/forward_list
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ template <class T, class Allocator, class Predicate>
#include <__algorithm/lexicographical_compare_three_way.h>
#include <__algorithm/min.h>
#include <__config>
#include <__cstddef/nullptr_t.h>
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/move_iterator.h>
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/new
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void operator delete[](void* ptr, void*) noexcept;
*/

#include <__config>
#include <__cstddef/max_align_t.h>
#include <__cstddef/size_t.h>
#include <__exception/exception.h>
#include <__type_traits/is_function.h>
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/string_view
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ namespace std {
#include <__algorithm/min.h>
#include <__assert>
#include <__config>
#include <__cstddef/nullptr_t.h>
#include <__cstddef/ptrdiff_t.h>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
// template<class T>
// strong_ordering operator<=>(shared_ptr<T> const& x, nullptr_t) noexcept; // C++20

#include <memory>
#include <cassert>
#include <cstddef>
#include <memory>

#include "test_macros.h"
#include "test_comparisons.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
// constexpr compare_three_way_result_t<typename unique_ptr<T, D>::pointer>
// operator<=>(const unique_ptr<T, D>& x, nullptr_t); // C++20

#include <memory>
#include <cassert>
#include <type_traits>
#include <cstddef>
#include <memory>

#include "test_macros.h"
#include "test_comparisons.h"
Expand Down
Loading