Movatterモバイル変換


[0]ホーム

URL:


This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-12-20


2470. Multiple array objects providing storage for one object

Section:6.8.2  [intro.object]    Status:CD6    Submitter:Andrey Erokhin    Date:2021-01-29

According to 6.8.2 [intro.object] paragraph 3,

If a complete object is created(7.6.2.8 [expr.new]) in storage associated withanother objecte of type “array ofNunsigned char” or of type “array ofNstd::byte” (17.2.1 [cstddef.syn]),that arrayprovides storage for the created objectif:

The intent of the third bullet is to select a unique arrayobject among those satisfying the first two bullets. However,it is possible to have multiple array objects of the samesize satisfying the first two bullets. For example:

  unsigned char buffer[8];  struct OhNo { std::byte data[8]; };  static_assert(sizeof(OhNo) == 8 && sizeof(int) == 4);  OhNo *p = new (buffer) OhNo;   //buffer provides storage forOhNo  int *q = new (p->data) int;    // who provides storage for this?  int *r = new (buffer + 4) int; // who provides storage for this?

Suggested resolution:

Change 6.8.2 [intro.object] bullet 3.3 as follows:

Proposed resolution (February, 2021):

Change 6.8.2 [intro.object] bullet 3.3 as follows:




[8]ページ先頭

©2009-2026 Movatter.jp