Re: Any experience with "The Last One"?

From: Sidney Cadot (sidney_at_jigsaw.nl)
Date: 11/28/03


Date: Fri, 28 Nov 2003 20:53:31 +0100

Dan Pop wrote:

> In <bq62k8$4vm$1@news.tudelft.nl> Sidney Cadot <sidney@jigsaw.nl> writes:
>
>
>>Dan Pop wrote:
>>
>>
>>>Side effects are irrelevant if the standard doesn't actually require the
>>>constructors to be called in this case, which is what we're arguing about.
>>>
>>>Side effects become relevant once we have established that the standard
>>>requires the constructors to be called.
>>
>>Oh Irony!
>>
>>It's about 5 cm below the standard quote you provided:
>>
>>"Footnote 31:
>>
>>An object in namespace scope having initialization with side-effects
>>must be initialized even if it is not used (3.7.1)."
>
>
> 6 In this International Standard, a term is italicized when it is first
> defined. In this International Standard, the examples, the notes, the
> footnotes, and the non-normative annexes are not part of the normative
> Standard.

This remark is nowhere to be found in ISO/IEC 14882, First Edition,
1998-09-01.

> And, of course, there is the question about *when* must the initialisation
> happen?

Ok, let's continue under the assumption that Footnote 31 applies, so
x[0], x[1], and x[2] must be initialized, implying constructor calls.
Let's also assume, then, that they will have to be destructed later on
in reverse order. Please stop me if I make unwarranted assumptions.

Given these assumptions, I'm curious as to what your own answer to your
question would be. You've asked a rhetorical question, which would
suggest that you think the answer is something like "the C++ standard
doesn't say". If that is the case, I think you're dead wrong.

Also, I think it would be much clearer if you just said "I think the C++
standard doesn't say" or something along these lines. Applying
rhetorical devices makes the discussion a lot murkier than it could be.

To revisit your question, I think it is quite equivalent to the
following, less vague formulation: "In the sample program, what are the
constraints on the order, relative to the body of main(), in which the
constructors and destructors of x[0], x[1], and x[2] must be called?"
Again, please feel free to *** in if I mis-represent something here.

To get our disagreement into unobstructed focus, bear with me to
consider to following three orders of execution for the constructors,
destructors, and main, in the small sample program. I've labelled them
for reference:

A. "sidney-I"

x[0] constructor
x[1] constructor
x[2] constructor
main()
x[2] destructor
x[1] destructor
x[0] destructor

B. "dan-I"

x[0] constructor
x[1] constructor
x[2] constructor
x[2] destructor
x[1] destructor
x[0] destructor
main()

C. "dan-II"

x[0] constructor
x[1] constructor
x[2] constructor
x[2] destructor
x[1] destructor
x[0] destructor
main()

Now I maintain the only allowed order is A. ("sidney-I"), while, if I am
correct, you maintain that (at least) the orders B. ("dan-I"), and C.
("dan-II") would also be allowed.

Is this a correct representation of our disagreement?

I am just making sure in preparation of some standard-digging.

Best regards,

   Sidney