Issue2254

Title 2254. Standard-layout classes and bit-fields
Status ready Section 12.2 [class.mem]
Submitter Richard Smith

Created on 2016-03-23.00:00:00 by admin, last changed by admin.

Messages
msg6179 (view) Date: 2018-03-15.00:00:00

Proposed resolution (March, 2018):

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

  2. Two objects a and b are pointer-interconvertible if:

    • ...

    • one is a standard-layout class object and the other is the first non-static data member of that object, or, if the object has no non-static data members, the first any base class subobject of that object (12.2 [class.mem]), or

    • ...

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

  4. If a standard-layout class object has any non-static data members, its address is the same as the address of its first non-static data member if that member is not a bit-field. Otherwise, its Its address is also the same as the address of each of its first base class subobjects (if any). [Note: There might therefore be unnamed padding within a standard-layout struct object inserted by an implementation, but not at its beginning, as necessary to achieve appropriate alignment. —end note] [Note: The object and its first subobject are pointer-interconvertible (6.9.2 [basic.compound], 8.2.9 [expr.static.cast]). —end note]
msg6178 (view) Date: 2018-03-15.00:00:00

Notes from the March, 2018 meeting:

It was pointed out that the definition of pointer interconvertibility in 6.7.2 [basic.stc.thread] paragraph 4 refers to “the first base class subobject” of the object and must also be updated to reflect the above proposed resolution.

msg5985 (view) Date: 2018-04-11.00:00:00

Proposed resolution, February, 2018: [SUPERSEDED]

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

If a standard-layout class object has any non-static data members, its address is the same as the address of its first non-static data member if that member is not a bit-field. Otherwise, its Its address is also the same as the address of each of its first base class subobjects (if any). [Note: There might therefore be unnamed padding within a standard-layout struct object inserted by an implementation, but not at its beginning, as necessary to achieve appropriate alignment. —end note] [Note: The object and its first subobject are pointer-interconvertible (6.9.2 [basic.compound], 8.2.9 [expr.static.cast]). —end note]
msg5892 (view) Date: 2018-02-27.00:00:00

According to 12.2 [class.mem] paragraph 25,

If a standard-layout class object has any non-static data members, its address is the same as the address of its first non-static data member. Otherwise, its address is the same as the address of its first base class subobject (if any). [Note: There might therefore be unnamed padding 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 are pointer-interconvertible (6.9.2 [basic.compound], 8.2.9 [expr.static.cast]). —end note]

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

History
Date User Action Args
2018-04-11 00:00:00adminsetstatus: tentatively ready -> ready
2018-04-11 00:00:00adminsetmessages: + msg6179
2018-04-11 00:00:00adminsetmessages: + msg6178
2018-02-27 00:00:00adminsetstatus: open -> tentatively ready
section: 9.2 [class.mem] -> 12.2 [class.mem]
title: Standard-layout classes and unnamed bit-fields -> Standard-layout classes and bit-fields
2018-02-27 00:00:00adminsetmessages: + msg5985
2016-03-23 00:00:00admincreate