[libcxx-commits] [libcxx] feat libcxx: avoid defining std::nullptr_t in terms of ::nullptr_t (PR #73442)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Nov 26 03:14:56 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Anton Zhilin (Anton3)
<details>
<summary>Changes</summary>
Before this PR, `<cstddef>` did
```cpp
using nullptr_t = ::nullptr_t;
```
`::nullptr_t` comes from `<stddef.h>` (of libc++), which uses `#include_next` to make the compiler look into glibc's `<stddef.h>` for the definition of `::nullptr_t`.
Such behavior confused some editors, notably CLion Nova, into thinking that `std::nullptr_t` does not exist, which turned off essentially all intellisense features.
The C++ Standard committee decided that `<stddef.h>` exposing `::nullptr_t` is a bug and that `std::nullptr_t` should not rely on `::nullptr_t`: https://timsong-cpp.github.io/lwg-issues/3484
---
Full diff: https://github.com/llvm/llvm-project/pull/73442.diff
1 Files Affected:
- (modified) libcxx/include/cstddef (+1-1)
``````````diff
diff --git a/libcxx/include/cstddef b/libcxx/include/cstddef
index 3844d4a373323db..3bb4d3b18102af7 100644
--- a/libcxx/include/cstddef
+++ b/libcxx/include/cstddef
@@ -56,7 +56,7 @@ Types:
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::nullptr_t;
+using nullptr_t = decltype(nullptr);
using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS;
using ::size_t _LIBCPP_USING_IF_EXISTS;
``````````
</details>
https://github.com/llvm/llvm-project/pull/73442
More information about the libcxx-commits
mailing list