Title
launder and base class subobjects
Status
nad
Section
[ptr.launder]
Submitter
Hubert Tong

Created on 2017-01-31.00:00:00 last changed 59 months ago

Messages

Date: 2020-02-14.09:37:04

Proposed resolution:

This wording is relative to N4618.

  1. Option 1:

    1. Modify [ptr.launder] as indicated:

      template <class T> constexpr T* launder(T* p) noexcept;
      

      -1- Requires: p represents the address A of a byte in memory. An object X that is within its lifetime ([basic.life]) and whose type is similar ([conv.qual]) to T is located at the address A. X shall either be a most derived object, or pointer-interconvertible with a most derived object that is within its lifetime. All bytes of storage that would be reachable through the result are reachable through p (see below).

  2. Option 2:

    1. Modify [ptr.launder] as indicated:

      template <class T> constexpr T* launder(T* p) noexcept;
      

      -1- Requires: p represents the address A of a byte in memory. An object X that is within its lifetime ([basic.life]) and whose type is similar ([conv.qual]) to T is located at the address A. If T is a polymorphic class type, then X shall be a most derived object. All bytes of storage that would be reachable through the result are reachable through p (see below).

Date: 2020-02-14.09:37:04

[ 2020-02 Status to NAD on Thursday night in Prague. ]

Date: 2017-08-15.00:00:00

[ 2017-08-14, CWG telecon note ]

Core recommends NAD after discussion in EWG.

Hubert Tong summarizes the outcome of that discussion as follows:

launder does not provide positive confirmation of the dynamic type of the object; it is intended that launder can be used to induce a devirtualization barrier even when the static type of the (sub)object to which the returned pointer refers is apparently consistent with prior accesses related to the source pointer.
Date: 2017-03-15.00:00:00

[ 2017-03-04, Kona ]

Set priority to 2. This was discussed in EWG (via a paper). Assign this (and 2859) to Core.

Date: 2017-01-31.00:00:00

There is an apparent oversight in the wording for launder that allows it to return base class subobjects which differ in their polymorphic behaviour between calls to launder.

This can be fixed by restricting launder from returning pointers to base class subobjects:

  1. always, or

  2. only for polymorphic class types.

History
Date User Action Args
2020-02-14 09:37:04adminsetmessages: + msg11103
2020-02-14 09:37:04adminsetstatus: open -> nad
2018-11-13 14:57:49adminsetstatus: core -> open
2017-10-27 17:26:06adminsetmessages: + msg9489
2017-03-14 03:14:09adminsetmessages: + msg9111
2017-03-14 03:14:09adminsetstatus: new -> core
2017-02-02 19:15:59adminsetmessages: + msg8839
2017-01-31 00:00:00admincreate