Is "subobject" a transitive relation?

35 views
Skip to first unread message

Language Lawyer

unread,
Aug 28, 2018, 7:11:21 PM8/28/18
to std-dis...@isocpp.org
subj

Richard Smith

unread,
Aug 28, 2018, 7:27:01 PM8/28/18
to std-dis...@isocpp.org
I think it depends on the context of the use, sadly. Strictly, subobject is not transitive, and an object is only a subobject in at most one way (it cannot be both an array element and a base class subobject, for instance), notwithstanding that a virtual base class subobject can be a subobject of multiple objects at once. Most uses of the term seem to use it in that way.

However, there are some uses that clearly intend to take the transitive closure:
 * [basic.stc.dynamic.safety]/2.2 intends to allow transitive subobjects (but should probably allow all objects nested within the original object)
 * [basic.types]/3's example says "subobject" but presumably means something more general
 * [basic.type.qualifier]/1.1, /1.2, /1.3 have ambiguous antecedents and could be reworded to make it clearer that they are transitive ("of such an object" -> "of a const object").
 * [basic.start.static]/2 intends to allow transitive subobjects
 * [conv.ptr]/3 intends to allow anything in the transitive closure of "base class subobject of".
... and so on. (I'm sure you can find more.)

Feel like filing an editorial issue? We should aim to use the term consistently.

On Tue, 28 Aug 2018 at 16:11, Language Lawyer <languag...@gmail.com> wrote:
subj

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussio...@isocpp.org.
To post to this group, send email to std-dis...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.

Language Lawyer

unread,
Aug 28, 2018, 8:34:35 PM8/28/18
to std-dis...@isocpp.org
On 29/08/18 04:26, Richard Smith wrote:
> I think it depends on the context of the use, sadly. Strictly, subobject is
> not transitive, and an object is only a subobject in at most one way (it
> cannot be both an array element and a base class subobject, for instance),
> notwithstanding that a virtual base class subobject can be a subobject of
> multiple objects at once. Most uses of the term seem to use it in that way.
>
> However, there are some uses that clearly intend to take the transitive
> closure:
> * [basic.stc.dynamic.safety]/2.2 intends to allow transitive subobjects
> (but should probably allow all objects nested within the original object)
> * [basic.types]/3's example says "subobject" but presumably means
> something more general
> * [basic.type.qualifier]/1.1, /1.2, /1.3 have ambiguous antecedents and
> could be reworded to make it clearer that they are transitive ("of such an
> object" -> "of a const object").
> * [basic.start.static]/2 intends to allow transitive subobjects
> * [conv.ptr]/3 intends to allow anything in the transitive closure of
> "base class subobject of".
> ... and so on. (I'm sure you can find more.)

[except.ctor]/3:
If the initialization or destruction of an object other than by delegating constructor is terminated by an exception, the destructor is invoked for each of the object's direct subobjects…
(Implies that subobjects can be indirect)

BTW, this wording seems to be defective even if we define "direct subobject".
How can a destructor be invoked for a member subobject of array type?
Reply all
Reply to author
Forward
0 new messages