Topic: Wording of standard: 15.5.2/1 "If a function ... throws an exception ...


Author: ivec@myrealbox.com ("Ivan Vecerina")
Date: Mon, 24 Feb 2003 19:56:25 +0000 (UTC)
Raw View
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.

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 ?

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 ?


Thanks in advance !

--
 Ivan Vecerina, Dr. med.  <>  http://www.post1.com/~ivec
 Soft Dev Manger, XiTact  <>  http://www.xitact.com
 Brainbench MVP for C++   <>  http://www.brainbench.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                       ]





Author: rmaddox@isicns.com (Randy Maddox)
Date: Tue, 25 Feb 2003 16:23:45 CST
Raw View
ivec@myrealbox.com ("Ivan Vecerina") wrote in message news:<3e57b3d9@news.swissonline.ch>...
> 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
> >>>

If, however, the exception never propogates beyond the function then
the stack unwinding for that function never occurs and unexpected is
not called.  At least that's how I read it, for what that's worth.
:-)

Randy.

>
> Thanks in advance !
>
> --
>  Ivan Vecerina, Dr. med.  <>  http://www.post1.com/~ivec
>  Soft Dev Manger, XiTact  <>  http://www.xitact.com
>  Brainbench MVP for C++   <>  http://www.brainbench.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                       ]





Author: jpotter@falcon.lhup.edu (John Potter)
Date: Wed, 26 Feb 2003 22:07:48 +0000 (UTC)
Raw View
On Tue, 25 Feb 2003 16:23:45 CST, rmaddox@isicns.com (Randy Maddox) wrote:

> If, however, the exception never propogates beyond the function then
> the stack unwinding for that function never occurs and unexpected is
> not called.  At least that's how I read it, for what that's worth.

Agreed.  If an exception does not escape a function, that function did
not throw.  I think that is the intent of the questioned phrase.

John

---
[ 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                       ]