|
615 | 615 | handler continues in a dynamically surrounding try block |
616 | 616 | of the same thread. |
617 | 617 |
|
| 618 | +\pnum |
| 619 | +\indextext{exception handling!terminate called@\tcode{terminate} called}% |
| 620 | +\indextext{\idxcode{terminate}!called}% |
| 621 | +If the search for a handler |
| 622 | +encounters the outermost block of a function with a |
| 623 | +non-throwing exception specification, |
| 624 | +the function \tcode{std::terminate}\iref{except.terminate} is invoked. |
| 625 | +\begin{note} |
| 626 | +An implementation is not permitted to reject an expression merely because, when |
| 627 | +executed, it throws or might |
| 628 | +throw an exception from a function with a non-throwing exception specification. |
| 629 | +\end{note} |
| 630 | +\begin{example} |
| 631 | +\begin{codeblock} |
| 632 | +extern void f(); // potentially-throwing |
| 633 | + |
| 634 | +void g() noexcept { |
| 635 | + f(); // valid, even if \tcode{f} throws |
| 636 | + throw 42; // valid, effectively a call to \tcode{std::terminate} |
| 637 | +} |
| 638 | +\end{codeblock} |
| 639 | +The call to |
| 640 | +\tcode{f} |
| 641 | +is well-formed despite the possibility for it to throw an exception. |
| 642 | +\end{example} |
| 643 | + |
| 644 | +\pnum |
| 645 | +If no matching handler is found, |
| 646 | +the function \tcode{std::terminate} is invoked; |
| 647 | +whether or not the stack is unwound before this invocation of |
| 648 | +\tcode{std::terminate} |
| 649 | +is \impldef{stack unwinding before invocation of |
| 650 | +\tcode{std::terminate}}\iref{except.terminate}. |
| 651 | + |
618 | 652 | \pnum |
619 | 653 | A handler is considered \defnx{active}{exception handling!handler!active} when |
620 | 654 | initialization is complete for the parameter (if any) of the catch clause. |
|
632 | 666 | still active is called the |
633 | 667 | \defnx{currently handled exception}{exception handling!currently handled exception}. |
634 | 668 |
|
635 | | -\pnum |
636 | | -If no matching handler is found, |
637 | | -the function \tcode{std::terminate} is invoked; |
638 | | -whether or not the stack is unwound before this invocation of |
639 | | -\tcode{std::terminate} |
640 | | -is \impldef{stack unwinding before invocation of |
641 | | -\tcode{std::terminate}}\iref{except.terminate}. |
642 | | - |
643 | 669 | \pnum |
644 | 670 | Referring to any non-static member or base class of an object |
645 | 671 | in the handler for a |
|
804 | 830 | has a non-throwing exception specification. |
805 | 831 | \end{example} |
806 | 832 |
|
807 | | -\pnum |
808 | | -\indextext{exception handling!terminate called@\tcode{terminate} called}% |
809 | | -\indextext{\idxcode{terminate}!called}% |
810 | | -Whenever an exception is thrown |
811 | | -and the search for a handler\iref{except.handle} |
812 | | -encounters the outermost block of a function with a |
813 | | -non-throwing exception specification, |
814 | | -the function \tcode{std::terminate} is invoked\iref{except.terminate}. |
815 | | -\begin{note} |
816 | | -An implementation is not permitted to reject an expression merely because, when |
817 | | -executed, it throws or might |
818 | | -throw an exception from a function with a non-throwing exception specification. |
819 | | -\end{note} |
820 | | -\begin{example} |
821 | | -\begin{codeblock} |
822 | | -extern void f(); // potentially-throwing |
823 | | - |
824 | | -void g() noexcept { |
825 | | - f(); // valid, even if \tcode{f} throws |
826 | | - throw 42; // valid, effectively a call to \tcode{std::terminate} |
827 | | -} |
828 | | -\end{codeblock} |
829 | | -The call to |
830 | | -\tcode{f} |
831 | | -is well-formed despite the possibility for it to throw an exception. |
832 | | -\end{example} |
833 | | - |
834 | 833 | \pnum |
835 | 834 | An expression $E$ is |
836 | 835 | \defnx{potentially-throwing}{potentially-throwing!expression} if |
|
0 commit comments