C++ rule on function-try-block
Hi all,
[ISO/IEC 14882:1998] A function-try-block associates a handler-seq
with the ctor-initializer, if present, and the function-body. An
exception thrown during the execution of the initializer expressions
in the ctor-initializer **or during the execution of the function-body
transfers control to a handler in a function-try-block in the same way
as an exception thrown during the execution of a try-block transfers
control to other handlers.**
To demonstrate the statement in between **...**, I cooked up the
following example (using VC++2010):
Given:
=====
class GenericError {};
void Print(int x)
{
if (x < 0) throw GenericError();
}
class X {
public:
X();
};
Case 1: // no error executing this
=====
X::X()
{
try
{
Print(-1);
}
catch(const GenericError& ge)
{
}
}
Case 2: // error while trying to execute this
======
X::X() try
{
Print(-1);
}
catch(const GenericError& ge)
{
}
According to the standard, the behavior for Case 1 and Case 2 should
be the same, right? But it is not in VC++2010. Is this a compiler
issue or what?
Thanks,
Muler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]