Skip to content

_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS breaks container constexpr-ness #69994

Closed
@jyknight

Description

@jyknight

As mentioned in #69466, if you set the _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS define, the restored allocator members are not constexpr, which leads to the vector and string types being non-constexpr too, because they find the deprecated allocator members, instead of going through allocator_traits as intended.

This is an extremely surprising result.

Other _LIBCPP_ENABLE_*_REMOVED_* flags do not change the behavior of normal conforming C++17/20 code, but just restore standalone functions/types, not affecting code which doesn't use them. I think that's generally a useful option to provide users of libc++, and would argue against removing most ENABLE_CXXNN_REMOVED options. (And, further, argue for adding more for future standards).

However, if the option breaks required semantics or is tricky to implement without the risk of breaking required semantics, then we should not provide it. Allocators/allocator_traits are certainly a very tricky area in that regard. Thus, I propose that libc++ should remove both the option _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS and _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION.

Sadly, Google's codebase is currently dependent upon this broken mode, and others may have similarly enabled it without realizing the negative impact. Thus, I propose to not immediately remove the options, but to phase it in:

  1. Now: announce the pending removal, stop implying them from the _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES define, and update the documentation accordingly.
  2. Approx February 2024 (after LLVM 18 release branch): remove support. [edited per comments below]

@ilya-biryukov @ldionne

Metadata

Metadata

Assignees

Labels

libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions