Title
P0767R1 breaks previously-standard-layout types
Status
c++20
Section
[meta.trans.other]
Submitter
Casey Carter

Created on 2017-11-12.00:00:00 last changed 46 months ago

Messages

Date: 2018-03-18.16:03:30

Proposed resolution:

This wording is relative to N4700 + P0767R1.

  1. Change in [support.types.layout] paragraph 5:

    The type max_align_t is a trivial standard-layout type whose alignment requirement is at least as great as that of every scalar type, and whose alignment requirement is supported in every context ([basic.align]).

  2. Change the table in [meta.trans.other] as indicated:

    aligned_storage
    The member typedef type shall be a trivial standard-layout type suitable for use as uninitialized storage for any object whose size is at most Len and whose alignment is a divisor of Align.

    aligned_union
    The member typedef type shall be a trivial standard-layout type suitable for use as uninitialized storage for any object whose type is listed in Types; its size shall be at least Len.

  3. Change [strings.general] paragraph 1 as indicated:

    This Clause describes components for manipulating sequences of any non-array trivial standard-layout ([basic.types]) type. Such types are called char-like types, and objects of char-like types are called char-like objects or simply characters.

Date: 2018-03-17.00:00:00

[ 2018-3-17 Adopted in Jacksonville ]

Date: 2017-11-14.00:00:00

[ 2017-11-14 Moved to Tentatively Ready after 8 positive votes for P0 on c++std-lib. ]

Date: 2017-11-12.00:00:00

P0767R1 "Expunge POD" changed the requirement for several library types from "POD" to "trivial." Since these types no longer provide/require the standard-layout portion of "POD," the change breaks:

  • user classes with a member of such a type that were standard-layout in C++17
  • implementations of basic_string and basic_string_view that expect character types to be both trivial and standard layout.
It appears this breakage was not intentional and not discussed in LWG.

The fix is straight-forward: apply an additional standard-layout requirement to the affected types:

  • max_align_t
  • the type member of specializations of aligned_storage
  • the type member of specializations of aligned_union
  • the char-like objects used by basic_string and basic_string_view.
(Albeit the potential for breakage with max_align_t is admittedly small.)

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2018-03-18 16:03:30adminsetmessages: + msg9747
2018-03-18 16:03:30adminsetstatus: voting -> wp
2018-02-12 01:13:49adminsetstatus: ready -> voting
2017-11-17 21:23:09adminsetmessages: + msg9562
2017-11-17 21:23:09adminsetstatus: new -> ready
2017-11-13 05:55:21adminsetmessages: + msg9548
2017-11-12 00:00:00admincreate