Topic: Wording of standard: 15.5.2/1 "If a function ... throws an
Author: dave@boost-consulting.com (David Abrahams)
Date: Mon, 24 Feb 2003 22:44:02 +0000 (UTC) Raw View
ivec@myrealbox.com ("Ivan Vecerina") writes:
> Here is the paragraph 15.5.2/1:
> <<< If a function with an exception-specification throws an
> exception that is not listed in the exception-specification,
> the function
> void unexpected();
> is called (18.6.2) immediately after completing
> the stack unwinding for the former function
>>>>
>
> The wording ("if a function throws an exception...") seems
> confusing. What if the function throws an exception that
> is caught before it reaches the outer scope of the function?
> void f() throw()
> {
> try{ throw 0; } catch(...){}
> }
> f() throws an exception, but it is caught before being
> propagated out of f(). As far as I know, unexpected()
> should not and will not be called.
I agree that it's wrong. What if the exception is thrown by a
function that f calls?
A function with an exception specification of throw() for example,
*never* throws.
> Paragraph 15.4/8 seems to provide a more precise
> and accurate description:
> <<< Whenever an exception is thrown and the search for a
> handler (15.3) encounters the outermost block of a
> function with an exception-specification, the function
> unexpected() is called (15.5.2) if the
> exception-specification does not allow the exception.
>>>>
>
> Should the wording of "15.5.2/1" be modified ?
Modified or stricken (not sure if it adds anything).
> For example:
> "If an exception not listed in the exception-specification
> of a function propagates out of this function, the
> function: void unexpected() ..... "
>
> ( Well, maybe without repeating 'function' 3 times... )
>
>
> I wouldn't be surprised if this point had already been
> discussed. Is there an easy way I could have checked
> that this has already been addressed ?
There's always the core issue list:
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_active.html
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]