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


2254. Standard-layout classes and bit-fields

Section:11.4  [class.mem]    Status:CD5    Submitter:Richard Smith    Date:2016-03-23

[Accepted as a DR at the June, 2018 (Rapperswil) meeting.]

According to 11.4 [class.mem] paragraph 25,

If a standard-layout class object has any non-static data members, itsaddress is the same as the address of its first non-static datamember. Otherwise, its address is the same as the address of its first baseclass subobject (if any). [Note: There might therefore be unnamedpadding within a standard-layout struct object, but not at its beginning,as necessary to achieve appropriate alignment. —end note][Note: The object and its first subobject arepointer-interconvertible (6.9.4 [basic.compound],7.6.1.9 [expr.static.cast]). —end note]

This wording does not consider the case when the first non-staticdata member is a bit-field, which cannot have its address taken.

Proposed resolution, February, 2018: [SUPERSEDED]

Change 11.4 [class.mem] paragraph 25 as follows:

If a standard-layout class object has any non-static data members, itsaddress is the same as the address of its first non-static datamemberif that member is not a bit-field.Otherwise, itsIts address isalso the same as the addressofeach of itsfirst base class subobjects(if any). [Note: There might therefore be unnamed paddingwithin a standard-layout struct objectinserted by animplementation, but not at its beginning, as necessary to achieveappropriate alignment. —end note] [Note: The object andits first subobject are pointer-interconvertible(6.9.4 [basic.compound], 7.6.1.9 [expr.static.cast]). —endnote]

Notes from the March, 2018 meeting:

It was pointed out that the definition of pointer interconvertibilityin 6.8.6.3 [basic.stc.thread] paragraph 4 refers to “the first baseclass subobject” of the object and must also be updated to reflectthe above proposed resolution.

Proposed resolution (March, 2018):

  1. Change 6.9.4 [basic.compound] bullet 4.3 as follows:

  2. Two objects a and b arepointer-interconvertible if:

  3. Change 11.4 [class.mem] paragraph 25 as follows:

  4. If a standard-layout class object has any non-static data members, itsaddress is the same as the address of its first non-static datamemberif that member is not a bit-field.Otherwise,itsIts address isalso the same as the addressofeach of itsfirst base class subobjects(if any). [Note: There might therefore be unnamed paddingwithin a standard-layout struct objectinserted by animplementation, but not at its beginning, as necessary to achieveappropriate alignment. —end note] [Note: The object andits first subobject are pointer-interconvertible(6.9.4 [basic.compound], 7.6.1.9 [expr.static.cast]). —endnote]



[8]ページ先頭

©2009-2026 Movatter.jp