Title
Creating objects in misaligned storage
Status
drwp
Section
6.7.3 [basic.align]
Submitter
Jiang An

Created on 2023-04-11.00:00:00 last changed 12 months ago

Messages

Date: 2023-04-28.19:41:23

Proposed resolution (approved by CWG 2023-04-28):

  1. Change in 6.7.3 [basic.align] paragraph 1 as follows:

    Object types have alignment requirements (6.8.2 [basic.fundamental], 6.8.4 [basic.compound]) which place restrictions on the addresses at which an object of that type may be allocated. An alignment is an implementation-defined integer value representing the number of bytes between successive addresses at which a given object can be allocated. An object type imposes an alignment requirement on every object of that type; stricter alignment can be requested using the alignment specifier (9.12.2 [dcl.align]). Attempting to create an object (6.7.2 [intro.object]) in storage that does not meet the alignment requirements of the object's type is undefined behavior.
  2. Change in 7.6.2.8 [expr.new] paragraph 22 as follows:

    [Note 11: When the allocation function returns a value other than null, it must be a pointer to a block of storage in which space for the object has been reserved. The block of storage is assumed to be appropriately aligned (6.7.3 [basic.align]) and of the requested size. The address of the created object will not necessarily be the same as that of the block if the object is an array. —end note]
Date: 2023-06-15.00:00:00

[Accepted as a DR at the June, 2023 meeting.]

A non-allocating form of operator new can be used to create an object in storage that is not suitably aligned for the type of the object. Such attempts ought to be undefined behavior.

History
Date User Action Args
2023-12-19 10:15:28adminsetstatus: dr -> drwp
2023-07-16 13:00:43adminsetstatus: ready -> dr
2023-04-28 19:41:23adminsetmessages: + msg7261
2023-04-28 19:41:23adminsetstatus: open -> ready
2023-04-11 00:00:00admincreate