Re: Any experience with "The Last One"?
From: Gerry Quinn (gerryq_at_indigo.ie)
Date: 11/27/03
- Next message: Dik T. Winter: "Re: [OT] Indian C programmers and "u""
- Previous message: Floyd Davidson: "Re: [OT] Indian C programmers and "u""
- In reply to: Dan Pop: "Re: Any experience with "The Last One"?"
- Next in thread: Dan Pop: "Re: Any experience with "The Last One"?"
- Reply: Dan Pop: "Re: Any experience with "The Last One"?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 27 Nov 2003 11:37:22 GMT
In article <bq21fr$lbl$9@sunnews.cern.ch>, Dan.Pop@cern.ch (Dan Pop) wrote:
>In <bq1p7g$g0h$1@news.tudelft.nl> Sidney Cadot <sidney@jigsaw.nl> writes:
>I thought it was less clear than that, in your trivial example.
>
>3 It is implementation-defined whether the dynamic initialization
> (_dcl.init_, _class.static_, _class.ctor_, _class.expl.init_) of an
> object of namespace scope with static storage duration is done before
> the first statement of main or deferred to any point in time after the
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> first statement of main but before the first use of a function or
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> object defined in the same translation unit.
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>So, is a conforming implementation *required* to ever execute the
>constructors in your program? Your program doesn't use *any* object or
>function it defines, does it?
I think there's probably a "but it must act as if it is initialised at
the start" clause somewhere.
But anyway, operator<<() is a function of an iostream object, not of
SampleClass, so the constructor cannot be called before it, and
therefore must be called before the first statement of main(), right?
I would argue that this should apply also to a function of SampleClass,
i.e. if it could not complete its own constructor without calling one of
its own functions, it should call the constructor before the first
statement of main().
An aggressive optimiser might kill off a class that was declared but
never used and has no side effects (unlike SampleClass). However this
would not be formally correct, I think, because suppose the class asked
for enough memory to invoke an exception? You can't guarantee no side
effects.
- Gerry Quinn
- Next message: Dik T. Winter: "Re: [OT] Indian C programmers and "u""
- Previous message: Floyd Davidson: "Re: [OT] Indian C programmers and "u""
- In reply to: Dan Pop: "Re: Any experience with "The Last One"?"
- Next in thread: Dan Pop: "Re: Any experience with "The Last One"?"
- Reply: Dan Pop: "Re: Any experience with "The Last One"?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|