cplusplus / nbballot

Handling of NB comments in response to ballots
14 stars 4 forks source link

GB-089 21.3 [type.traits] Missing trait for implicit lifetime types #457

Closed wg21bot closed 1 year ago

wg21bot commented 1 year ago

There are certain operations that are only valid for implicit-lifetime types. In particular, in certain situations the lifetime of an object of implicit- lifetime type can be implicitly started by operations such as malloc, where otherwise the code would be undefined behaviour due to a violation of the C++ object lifetime rules. Additionally, in C++23 we are adding the possibility to start the lifetime of such objects explicitly with std::start_lifetime_as<T> [P2590R2].

Unfortunately, C++ lacks the ability to programmatically check whether a type is an implicit-lifetime type, and to constrain functions using such operations to only be valid for such types. This is particularly important to help catch a possible regression: if a type that was once implicit-lifetime mistakenly loses that property as a part of a change, this silently turns previously correct code into undefined behaviour. To fix this issue, we should add the type trait std::is_implicit_lifetime<T>, as proposed by P2674R0. Because this is necessary to avoid a class of bugs, we consider this proposal a bugfix, rather than a new feature request, and recommend to adopt it in the C++23 timeframe.

Adopt the changes proposed in P2674R0.

JeffGarland commented 1 year ago

Related Paper: https://github.com/cplusplus/papers/issues/1340

jfbastien commented 1 year ago

Moving to EWG since the associated paper is tagged for EWG.

erichkeane commented 1 year ago

Recommend that LEWG adopt P2674R0 as proposed adding a feature test macro for C++23.

SF F N A SA
4 17 0 2 0

Result: Consensus

Additionally recommend that LEWG consider adding this as a concept as well, or instead of, as a type trait.

SF F N A SA
3 5 8 5 0

Result: Not Consensus

FabioFracassi commented 1 year ago

TODO: Bryce Add Polls and notes

jensmaurer commented 1 year ago

CWG 2022-11-09: We have seen D2674R1 and have no concerns, with or without CWG2605 applied.

jwakely commented 1 year ago

Accepted with modification.