Re: throw without try or catch block
On Jun 16, 10:50 pm, Matthias Berndt <matthias_ber...@gmx.de> wrote:
1. can you throw without a try/catch block - is this legal?
Of course, that's the point. Otherwise, there would hardly be a
difference between an exception and a simple goto statement.
2. if you can, why am I getting a warning at those throw statements.
How are we supposed to know? You didn't tell us what the warning says.
{ quoted banner removed. DON'T quote extraneous material. tia., -mod }
I did tell,
The warning says, - "Will never be executed "
Another example is a place like this...
if (ret==NULL)
{
throw new std::runtime_error("Could not start/reset timer"); <--
why?
}
The fact that I am getting a warning("Will never be executed") at
throw statement , implies that compiler is not optimizing away the if
check, because had that been the case , I would have gotten the
warning at the opening braces {
Is my reasoning right?
How can I get rid of this warning, while preserving the original code.
Thanks,
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]