Topic: What does rethrow_nested throw?
Author: "Thomas J. Gritzan" <phygon_antispam@gmx.de>
Date: Fri, 22 May 2009 02:10:21 CST Raw View
restor schrieb:
> Hi,
> N2857 in 18.8.6:4 describes nested_exception::rethrow_nested as
> follows:
>
> void rethrow_nested() const; // [[noreturn]]
> Throws: the stored exception captured by this nested_exception object.
>
> It is marked as [[noreturn]]. What does it throw if stored exception
> is a null exception_ptr object?
Question:
How to construct a nested_exception object with a null exception_ptr in it?
--
Thomas
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: Sean Hunt <rideau3@gmail.com>
Date: Fri, 22 May 2009 02:06:07 CST Raw View
On May 21, 5:22 pm, restor <akrze...@interia.pl> wrote:
> Hi,
> N2857 in 18.8.6:4 describes nested_exception::rethrow_nested as
> follows:
>
> void rethrow_nested() const; // [[noreturn]]
> Throws: the stored exception captured by this nested_exception object.
>
> It is marked as [[noreturn]]. What does it throw if stored exception
> is a null exception_ptr object?
As I understand it, such a circumstance cannot occur; the
implementation will have called terminate() if you try to construct a
nested_exception when there is no current exception.
Sean Hunt
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: restor <akrzemi1@interia.pl>
Date: Fri, 22 May 2009 12:43:49 CST Raw View
On 22 May, 10:06, Sean Hunt <ride...@gmail.com> wrote:
> On May 21, 5:22 pm, restor <akrze...@interia.pl> wrote:
>
> > Hi,
> > N2857 in 18.8.6:4 describes nested_exception::rethrow_nested as
> > follows:
>
> > void rethrow_nested() const; // [[noreturn]]
> > Throws: the stored exception captured by this nested_exception object.
>
> > It is marked as [[noreturn]]. What does it throw if stored exception
> > is a null exception_ptr object?
>
> As I understand it, such a circumstance cannot occur; the
> implementation will have called terminate() if you try to construct a
> nested_exception when there is no current exception.
this is a piece of code that creates std::nested_exception with null
exception_ptr;
int main() try {
S1: std::nested_exception exc;
S2: exc.rethrow_nested();
}
catch(...) {
}
The default constructor calls std::current_exception, which returns
null pointer if
no exception is currently being handled. The statement at S1 does not
call terminate.
Now, by writing the statement S1, I probably proved that I do not
understand the purpose of nested_exception, because there is no point
in having one with a null, but according to the standard it is
perfectly legal.
We could say that S2 should call terminate if there is nothing to
throw, and the function cannot return (this makes sense), but the
N2857 says no such thing. rethrow_nested is required to throw what it
points to rather than rethrowing currently handled exception, so the
"rethrow; triggers terminate" paragraph (15.1:8) does not apply.
Regards,
&rzej
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: restor <akrzemi1@interia.pl>
Date: Thu, 21 May 2009 17:22:29 CST Raw View
Hi,
N2857 in 18.8.6:4 describes nested_exception::rethrow_nested as
follows:
void rethrow_nested() const; // [[noreturn]]
Throws: the stored exception captured by this nested_exception object.
It is marked as [[noreturn]]. What does it throw if stored exception
is a null exception_ptr object?
Regards,
&rzej
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]