llvm-project/libcxx/include/__memory
Arthur O'Dwyer dadbe88a13 [libc++] Fix std::to_address(array).
There were basically two bugs here:

When C++20 `to_address` is called on `int arr[10]`, then `const _Ptr&` becomes
a reference to a const array, and then we dispatch to `__to_address<const int(&)[10]>`,
which, oops, gives us a `const int*` result instead of an `int*` result.
Solution: We need to provide the two standard-specified overloads of
`std::to_address` in exactly the same way that we provide two overloads
of `__to_address`.

When `__to_address` is called on a pointer type, `__to_address(const _Ptr&)`
is disabled so we successfully avoid trying to instantiate pointer_traits of
that pointer type. But when it's called on an array type, it's not disabled
for array types, so we go ahead and instantiate pointer_traits<int[10]>,
which goes boom. Solution: We need to disable `__to_address(const _Ptr&)`
for both pointer and array types. Also disable it for function types,
so that they get the nice error message; and put a test on it.

Differential Revision: https://reviews.llvm.org/D109331
2021-09-07 13:56:25 -04:00
..
addressof.h [libc++][NFC] Remove useless _LIBCPP_PUSH_MACROS 2021-08-27 12:41:55 -04:00
allocation_guard.h [libc++][NFC] Remove useless _LIBCPP_PUSH_MACROS 2021-08-27 12:41:55 -04:00
allocator.h [libc++][NFC] Remove useless _LIBCPP_PUSH_MACROS 2021-08-27 12:41:55 -04:00
allocator_arg_t.h [libc++] Remove workarounds for [[nodebug]] not working properly on typedefs in older Clangs 2021-09-01 10:51:09 -04:00
allocator_traits.h [libc++] Remove workarounds for [[nodebug]] not working properly on typedefs in older Clangs 2021-09-01 10:51:09 -04:00
auto_ptr.h [libc++][NFC] Remove useless _LIBCPP_PUSH_MACROS 2021-08-27 12:41:55 -04:00
compressed_pair.h [libc++] Remove workarounds for [[nodebug]] not working properly on typedefs in older Clangs 2021-09-01 10:51:09 -04:00
construct_at.h [libc++][NFC] Remove useless _LIBCPP_PUSH_MACROS 2021-08-27 12:41:55 -04:00
pointer_safety.h [libc++][NFC] Remove useless _LIBCPP_PUSH_MACROS 2021-08-27 12:41:55 -04:00
pointer_traits.h [libc++] Fix std::to_address(array). 2021-09-07 13:56:25 -04:00
raw_storage_iterator.h [libc++][NFC] Remove useless _LIBCPP_PUSH_MACROS 2021-08-27 12:41:55 -04:00
shared_ptr.h [libc++] Remove workarounds for [[nodebug]] not working properly on typedefs in older Clangs 2021-09-01 10:51:09 -04:00
temporary_buffer.h [libc++][NFC] Remove useless _LIBCPP_PUSH_MACROS 2021-08-27 12:41:55 -04:00
uninitialized_algorithms.h [libc++][NFC] Remove useless _LIBCPP_PUSH_MACROS 2021-08-27 12:41:55 -04:00
unique_ptr.h [libc++] Remove workarounds for [[nodebug]] not working properly on typedefs in older Clangs 2021-09-01 10:51:09 -04:00
uses_allocator.h [libcxx][functional][modular] splices <functional> into modular headers 2021-07-01 14:01:49 -04:00