Index: libcfa/src/exception.c
===================================================================
--- libcfa/src/exception.c	(revision 92976d95c1f6c8e40dc04d8a5960b056a5f6def8)
+++ libcfa/src/exception.c	(revision 7df014f0c8d01759be9f0064f85ce9e32b980b1a)
@@ -10,6 +10,6 @@
 // Created On       : Mon Jun 26 15:13:00 2017
 // Last Modified By : Andrew Beach
-// Last Modified On : Mon Apr 06 14:40:00 2020
-// Update Count     : 15
+// Last Modified On : Thr Apr  9 12:20:00 2020
+// Update Count     : 17
 //
 
@@ -28,4 +28,5 @@
 #include <unwind.h>
 #include <bits/debug.hfa>
+#include "stdhdr/assert.h"
 
 // FIX ME: temporary hack to keep ARM build working
@@ -216,8 +217,13 @@
 		struct _Unwind_Context * unwind_context,
 		void * stop_param) {
-	if ( actions & _UA_END_OF_STACK  ) exit(1);
-	if ( actions & _UA_CLEANUP_PHASE ) return _URC_NO_REASON;
-
-	return _URC_FATAL_PHASE2_ERROR;
+	// Verify actions follow the rules we expect.
+	verify((actions & _UA_CLEANUP_PHASE) && actions & (_UA_FORCE_UNWIND));
+	verify(!(actions & (_UA_SEARCH_PHASE | _UA_HANDER_FRAME)));
+
+	if ( actions & _UA_END_OF_STACK ) {
+		exit(1);
+	} else {
+		return _URC_NO_REASON;
+	}
 }
 
@@ -282,17 +288,22 @@
 			version, actions, exception_class, unwind_exception, unwind_context);
 
-	// If we've reached the end of the stack then there is nothing much we can do...
-	if (actions & _UA_END_OF_STACK) return _URC_END_OF_STACK;
-
+	// Verify that actions follow the rules we expect.
+	// This function should never be called at the end of the stack.
+	verify(!(actions & _UA_END_OF_STACK));
+	// Either only the search phase flag is set or...
 	if (actions & _UA_SEARCH_PHASE) {
+		verify(actions == _UA_SEARCH_PHASE);
 		__cfaabi_dbg_print_safe(" lookup phase");
-	}
-	else if (actions & _UA_CLEANUP_PHASE) {
+	// ... we are in clean-up phase.
+	} else {
+		verify(actions & _UA_CLEANUP_PHASE);
 		__cfaabi_dbg_print_safe(" cleanup phase");
-	}
-	// Just in case, probably can't actually happen
-	else {
-		printf(" error\n");
-		return _URC_FATAL_PHASE1_ERROR;
+		// We shouldn't be the handler frame during forced unwind.
+		if (actions & _UA_HANDLER_FRAME) {
+			verify(!(actions & _UA_FORCE_UNWIND));
+			__cfaabi_dbg_print_safe(" (handler frame)");
+		} else if (actions & _UA_FORCE_UNWIND) {
+			__cfaabi_dbg_print_safe(" (force unwind)");
+		}
 	}
 
@@ -396,5 +407,5 @@
 			// This is only a cleanup handler, ignore it
 			__cfaabi_dbg_print_safe(" no action");
-		} else if (actions & _UA_CLEANUP_PHASE) {
+		} else {
 			// In clean-up phase, no destructors here but this could be the handler.
 
@@ -434,5 +445,5 @@
 
 #pragma GCC push_options
-#pragma GCC optimize("O0")
+#pragma GCC optimize("no-toplevel-reorder")
 
 // Try statements are hoisted out see comments for details. While this could probably be unique
