cplusplus / CWG

Core Working Group
23 stars 7 forks source link

[basic.stc] Conflicting storage durations of created subobjects #527

Open frederick-vs-ja opened 2 months ago

frederick-vs-ja commented 2 months ago

Full name of submitter (unless configured in github; will be published with the issue): Jiang An

Reference (section label): [intro.object], [basic.stc.general], [basic.stc.inherit], [class.union.general]

Link to reflector thread (if any):

Issue description:

Per [basic.stc.inherit] p1, a subobject has the same storage duration as its complete object. However, per [intro.object] p2, the subobject may be originally created by a new-expression or implicitly and then considered to be a subobject (see also discussion in #386), and a variant member of a union object may also considered implicitly created ([class.union.general] p5). And [basic.stc.general] p2 (amended by CWG2533) specifies the created object in such a case to have dynamic storage duration.

When the complete object has static, thread, or automatic storage duration, the current rules are contradictory.

Suggested resolution: