try {
static Foo foo; // ctor may throw an exception
} catch (...) {
;
}
Does the standard guarantee that the exception thrown by Foo ctor
will be caught ?
6.7.4 allows early initialization of local objects with static storage
under certain conditions provided by 3.6.2
3.6.2 says : "the static version of the initialization produces
the same value in the initialized object as would be produced by
the dynamic initialization if all objects not required to be initialized
statically were initialized dynamically".
Does it mean that if a local static object ctor may throw an exception
then early initialization of that object is not allowed ?
Regards,
Misha
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
I believe that by static initialization, or early initialization, the
standard means that the object's value may be built into the memory image of
the program. The only things that can be part of the memory image are things
that can be computed by the compiler, and that would seem to rule out
anything that could throw an exception.
Besides, 6.7 p4 mentions the possibility of an exception being thrown while
computing the value for the static object, and says that the computation
will be retried if the declaration is ever reexecuted. If the computation
were allowed to occur early, it would result in an unhandled exception, so
could never be retried. I think the intent is clear.
--
Ciao, Paul D. DeRocco
Paul mailto:pder...@ix.netcom.com