You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
extern X xobj;
int* p3 = &xobj.i; // OK, X is a trivial class
X xobj;
Although the example does not violate [class.cdtor] p1, however, [class.cdtor] p3 says
To form a pointer to (or access the value of) a direct non-static member of an object obj, the construction of obj shall have started and its destruction shall not have completed, otherwise the computation of the pointer value (or accessing the member value) results in undefined behavior.
In this example, we do form a pointer to a direct non-static member(i) of an object xobj, and the construction of xobj have not started at the point of the second line, the above rule explicitly says that the computation of the pointer value results in UB. So, Is the comment wrong?
The text was updated successfully, but these errors were encountered:
IMO that the restrictions should be relaxed. I've sent a mail for this in order to submit a CWG issue.CWG1517 has already been opened for this.
Taking the address of a virtual base class subobject or its subobject before construction or after destruction should remain undefined, because the vptr is probably invalid. But in other cases, the behavior should be made well-defined.
Although the example does not violate [class.cdtor] p1, however, [class.cdtor] p3 says
In this example, we do form a pointer to a direct non-static member(
i
) of an objectxobj
, and the construction ofxobj
have not started at the point of the second line, the above rule explicitly says that the computation of the pointer value results in UB. So, Is the comment wrong?The text was updated successfully, but these errors were encountered: