forked from OSchip/llvm-project
![]() 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 |
||
---|---|---|
.. | ||
addressof.h | ||
allocation_guard.h | ||
allocator.h | ||
allocator_arg_t.h | ||
allocator_traits.h | ||
auto_ptr.h | ||
compressed_pair.h | ||
construct_at.h | ||
pointer_safety.h | ||
pointer_traits.h | ||
raw_storage_iterator.h | ||
shared_ptr.h | ||
temporary_buffer.h | ||
uninitialized_algorithms.h | ||
unique_ptr.h | ||
uses_allocator.h |