static void fneDispatch( // DISPATCH "unexpected" DISPATCH_EXC *dispatch ) // - dispatch control { THREAD_CTL *ctl; // - thread-specific data ACTIVE_EXC *exc; // - active exception ACTIVE_EXC *srch; // - previous exception for this FNEXC ctl = dispatch->rtc->thr; ctl->abort_msg = RTMSG_FNEXC; exc = ctl->excepts; exc->dispatch = dispatch; for( srch = exc; ; ) { if( srch == NULL ) { // first time through fn_exc exc->dispatch = dispatch; exc->fnexc_state = exc->state; exc->state = EXCSTATE_UNEXPECTED; _EXC_PR_FNEXC marker( dispatch->rtc , 0 , dispatch->rw , dispatch->rethrow ? 0 : exc ); unexpected(); marker._state = EXCSTATE_TERMINATE; CPPLIB( call_terminate )( RTMSG_RET_UNEXPECT, ctl ); // never return } DISPATCH_EXC *cand = srch->dispatch; if( NULL != cand && dispatch->rw == cand->rw && dispatch->state_var == cand->state_var ) { if( srch->state == EXCSTATE_UNEXPECTED ) { // throw/rethrow did not get through fn-exc exc->state = EXCSTATE_BAD_EXC; _EXC_PR_FNEXC marker( dispatch->rtc , 0 , dispatch->rw , dispatch->rethrow ? 0 : exc ); throw bad_exception(); } if( srch->state == EXCSTATE_BAD_EXC ) { // throw of bad_exception did not get through fn-exc _EXC_PR_DTOR marker( dispatch->rtc , 0 , EXCSTATE_TERMINATE , dispatch->rethrow ? 0 :exc ); CPPLIB( call_terminate )( RTMSG_FNEXC, ctl ); // never return } if( srch != exc ) { CPPLIB( corrupted_stack )(); // never return } } srch = srch->prev; if( exc == srch ) { CPPLIB( corrupted_stack )(); // never return } } }
void __throw_bad_exception() { throw bad_exception(); }