This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of WP status.

4113. Disallow has_unique_object_representations<Incomplete[]>

Section: 21.3.5.4 [meta.unary.prop] Status: WP Submitter: Jonathan Wakely Opened: 2024-06-25 Last modified: 2024-11-28

Priority: Not Prioritized

View other active issues in [meta.unary.prop].

View all other issues in [meta.unary.prop].

View all issues with WP status.

Discussion:

The type completeness requirements for has_unique_object_representations say:

T shall be a complete type, cv void, or an array of unknown bound.

This implies that the trait works for all arrays of unknown bound, whether the element type is complete or not. That seems to be incorrect, because has_unique_object_representations_v<Incomplete[]> is required to have the same result as has_unique_object_representations_v<Incomplete> which is ill-formed if Incomplete is an incomplete class type.

I think we need the element type to be complete to be able to give an answer. Alternatively, if the intended result for an array of unknown bound is false (maybe because there can be no objects of type T[], or because we can't know that two objects declared as extern T a[]; and extern T b[]; have the same number of elements?) then the condition for the trait needs to be special-cased as false for arrays of unknown bound. The current spec is inconsistent, we can't allow arrays of unknown bound and apply the current rules to determine the trait's result.

[2024-08-02; Reflector poll]

Set status to Tentatively Ready after nine votes in favour during reflector poll.

[Wrocław 2024-11-23; Status changed: Voting → WP.]

Proposed resolution:

This wording is relative to N4981.

  1. Modify 21.3.5.4 [meta.unary.prop] as indicated:

    TemplateConditionPreconditions
    template<class T>
    struct has_unique_object_representations;
    For an array type T, the same result as has_unique_object_representations_v<remove_all_extents_t<T>>, otherwise see below. remove_all_extents_t<T> T shall be a complete type, or cv void, or an array of unknown bound.

    [Drafting note: We could use remove_extent_t<T> to remove just the first array dimension, because only that first one can have an unknown bound. The proposed resolution uses remove_all_extents_t<T> for consistency with the Condition column.]