Title
Preconditions of reference_constructs_from_temporary/reference_converts_from_temporary seem wrong
Status
new
Section
[meta.unary.prop]
Submitter
Jiang An

Created on 2022-05-10.00:00:00 last changed 1 month ago

Messages

Date: 2022-05-17.11:58:16

Proposed resolution:

This wording is relative to N4910.

  1. Modify [meta.type.synop], Table 46 ([tab:meta.unary.prop]) — "Type property predicates" — as indicated:

    Table 46: Type property predicates [tab:meta.unary.prop]
    Template Condition Preconditions
    template<class T, class U>
    struct reference_constructs_from_temporary;
    conjunction_v<is_reference<T>, is_constructible<T, U>> is
    true, and the initialization T t(VAL<U>); binds t to a
    temporary object whose lifetime is extended ([class.temporary]).
    If T is a reference type, remove_reference_t<T>
    and U
    T shall be a complete types,
    cv void, or an arrays of unknown bound.
    template<class T, class U>
    struct reference_converts_from_temporary;
    conjunction_v<is_reference<T>, is_convertible<U, T>> is
    true, and the initialization T t = VAL<U>; binds t to a
    temporary object whose lifetime is extended ([class.temporary]).
    If T is a reference type, remove_reference_t<T>
    and U shall be complete types,
    cv void, or arrays of unknown bound.
Date: 2022-05-15.00:00:00

[ 2022-05-17; Reflector poll ]

Set priority to 3 after reflector poll.

Date: 2022-05-10.00:00:00

std::reference_constructs_from_temporary and std::reference_converts_from_temporary are only useful when T is a reference type, and a reference type is always complete. Whenever T is an incomplete object type, it's clear that these traits inherit from std::false_type, without any further detection which may result in UB. However, when T is X& or X&& where X is an incomplete object type, UB may be needed because of the potentially problematic detection in std::is_constructible or std::is_convertible.

I'm not sure whether the general rule in [meta.rqmts]/5 affects these cases.

History
Date User Action Args
2022-05-17 11:58:16adminsetmessages: + msg12468
2022-05-14 11:41:32adminsetmessages: + msg12449
2022-05-10 00:00:00admincreate