-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Closed as not planned
Labels
invalidResolved as invalid, i.e. not a bugResolved as invalid, i.e. not a buglibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Description
This code should technically be allowed per C++20 standard (int *const meets the requirement of MoveInsertable and Erasable):
#include <vector>
int main() {
std::vector<int* const> foo;
foo.push_back(nullptr);
}However, when I build with clang++ -std=c++20 using libc++ from close to head, I get a compiler error:
../include/c++/v1/__algorithm/move.h:42:17: error: cannot assign to return value because function 'operator*' returns a const value
42 | *__result = _IterOps<_AlgPolicy>::__iter_move(__first);
...
<source>:5:9: note: in instantiation of member function 'std::vector<const int *const>::push_back' requested here
5 | foo.push_back(nullptr);
Compiling with -std=c++17 produces no errors. I believe this is somehow related to allocators, because specifying -D_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS and -D_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION with -std=c++20 makes this code compile again.
See godbolt too.
Metadata
Metadata
Assignees
Labels
invalidResolved as invalid, i.e. not a bugResolved as invalid, i.e. not a buglibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.