Index: src/main.cc
===================================================================
--- src/main.cc	(revision 07de76bb7a0e1179ac6fb9bae0cb96e709315c84)
+++ src/main.cc	(revision bffcd663a600d87ff5b237df6c2c43c0d99f2c02)
@@ -10,6 +10,6 @@
 // Created On       : Fri May 15 23:12:02 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Aug 23 06:50:08 2019
-// Update Count     : 607
+// Last Modified On : Fri Dec 13 23:47:06 2019
+// Update Count     : 626
 //
 
@@ -20,5 +20,5 @@
 #include <cstdio>                           // for fopen, FILE, fclose, stdin
 #include <cstdlib>                          // for exit, free, abort, EXIT_F...
-#include <csignal>                         // for signal, SIGABRT, SIGSEGV
+#include <csignal>                          // for signal, SIGABRT, SIGSEGV
 #include <cstring>                          // for index
 #include <fstream>                          // for ofstream
@@ -28,4 +28,7 @@
 #include <list>                             // for list
 #include <string>                           // for char_traits, operator<<
+
+using namespace std;
+
 
 #include "CompilationState.h"
@@ -53,5 +56,4 @@
 #include "InitTweak/GenInit.h"              // for genInit
 #include "MakeLibCfa.h"                     // for makeLibCfa
-#include "Parser/LinkageSpec.h"             // for Spec, Cforall, Intrinsic
 #include "Parser/ParseNode.h"               // for DeclarationNode, buildList
 #include "Parser/TypedefTable.h"            // for TypedefTable
@@ -59,4 +61,5 @@
 #include "ResolvExpr/Resolver.h"            // for resolve
 #include "SymTab/Validate.h"                // for validate
+#include "SynTree/LinkageSpec.h"            // for Spec, Cforall, Intrinsic
 #include "SynTree/Declaration.h"            // for Declaration
 #include "SynTree/Visitor.h"                // for acceptAll
@@ -64,6 +67,4 @@
 #include "Virtual/ExpandCasts.h"            // for expandCasts
 
-
-using namespace std;
 
 static void NewPass( const char * const name ) {
@@ -97,5 +98,5 @@
 static bool waiting_for_gdb = false;					// flag to set cfa-cpp to wait for gdb on start
 
-static std::string PreludeDirector = "";
+static string PreludeDirector = "";
 
 static void parse_cmdline( int argc, char *argv[] );
@@ -153,16 +154,35 @@
 } // backtrace
 
-static void sigSegvBusHandler( int sig_num ) {
-	cerr << "*CFA runtime error* program cfa-cpp terminated with "
-		 <<	(sig_num == SIGSEGV ? "segment fault" : "bus error")
-		 << "." << endl;
+#define SIGPARMS int sig __attribute__(( unused )), siginfo_t * sfp __attribute__(( unused )), ucontext_t * cxt __attribute__(( unused ))
+
+static void Signal( int sig, void (*handler)(SIGPARMS), int flags ) {
+	struct sigaction act;
+
+	act.sa_sigaction = (void (*)(int, siginfo_t *, void *))handler;
+	sigemptyset( &act.sa_mask );
+	sigaddset( &act.sa_mask, SIGALRM );					// disabled during signal handler
+	sigaddset( &act.sa_mask, SIGUSR1 );
+	act.sa_flags = flags;
+
+	if ( sigaction( sig, &act, nullptr ) == -1 ) {
+	    cerr << "*CFA runtime error* problem installing signal handler, error(" << errno << ") " << strerror( errno ) << endl;
+	    _exit( EXIT_FAILURE );
+	} // if
+} // Signal
+
+static void sigSegvBusHandler( SIGPARMS ) {
+	if ( sfp->si_addr == nullptr ) {
+		cerr << "Null pointer (nullptr) dereference." << endl;
+	} else {
+		cerr << (sig == SIGSEGV ? "Segment fault" : "Bus error") << " at memory location " << sfp->si_addr << "." << endl
+			 << "Possible cause is reading outside the address space or writing to a protected area within the address space with an invalid pointer or subscript." << endl;
+	} // if
 	backtrace( 2 );										// skip first 2 stack frames
-	//_exit( EXIT_FAILURE );
 	abort();											// cause core dump for debugging
 } // sigSegvBusHandler
 
-static void sigAbortHandler( __attribute__((unused)) int sig_num ) {
+static void sigAbortHandler( SIGPARMS ) {
 	backtrace( 6 );										// skip first 6 stack frames
-	signal( SIGABRT, SIG_DFL);							// reset default signal handler
+	Signal( SIGABRT, (void (*)(SIGPARMS))SIG_DFL, SA_SIGINFO );	// reset default signal handler
 	raise( SIGABRT );									// reraise SIGABRT
 } // sigAbortHandler
@@ -173,11 +193,11 @@
 	list< Declaration * > translationUnit;
 
-	signal( SIGSEGV, sigSegvBusHandler );
-	signal( SIGBUS, sigSegvBusHandler );
-	signal( SIGABRT, sigAbortHandler );
-
-	// std::cout << "main" << std::endl;
+	Signal( SIGSEGV, sigSegvBusHandler, SA_SIGINFO );
+	Signal( SIGBUS, sigSegvBusHandler, SA_SIGINFO );
+	Signal( SIGABRT, sigAbortHandler, SA_SIGINFO );
+
+	// cout << "main" << endl;
 	// for ( int i = 0; i < argc; i += 1 ) {
-	// 	std::cout << '\t' << argv[i] << std::endl;
+	// 	cout << '\t' << argv[i] << endl;
 	// } // for
 
@@ -186,7 +206,7 @@
 
 	if ( waiting_for_gdb ) {
-		std::cerr << "Waiting for gdb" << std::endl;
-		std::cerr << "run :" << std::endl;
-		std::cerr << "  gdb attach " << getpid() << std::endl;
+		cerr << "Waiting for gdb" << endl;
+		cerr << "run :" << endl;
+		cerr << "  gdb attach " << getpid() << endl;
 		raise(SIGSTOP);
 	} // if
@@ -388,13 +408,13 @@
 		return EXIT_FAILURE;
 	} catch ( ... ) {
-		std::exception_ptr eptr = std::current_exception();
+		exception_ptr eptr = current_exception();
 		try {
 			if (eptr) {
-				std::rethrow_exception(eptr);
+				rethrow_exception(eptr);
 			} else {
-				std::cerr << "Exception Uncaught and Unknown" << std::endl;
-			} // if
-		} catch(const std::exception& e) {
-			std::cerr << "Uncaught Exception \"" << e.what() << "\"\n";
+				cerr << "Exception Uncaught and Unknown" << endl;
+			} // if
+		} catch(const exception& e) {
+			cerr << "Uncaught Exception \"" << e.what() << "\"\n";
 		} // try
 		return EXIT_FAILURE;
