Index: src/InitTweak/FixInit.cc
===================================================================
--- src/InitTweak/FixInit.cc	(revision 5b40f300c07c8cd0b5d1720f42e535c1f4926bd5)
+++ src/InitTweak/FixInit.cc	(revision 5b2f5bb4b0269a726d7840b6f270858c3ff12d9a)
@@ -10,5 +10,5 @@
 // Created On       : Wed Jan 13 16:29:30 2016
 // Last Modified By : Rob Schluntz
-// Last Modified On : Tue Jan 19 16:36:59 2016
+// Last Modified On : Wed Mar 30 14:34:46 2016
 // Update Count     : 30
 //
@@ -37,4 +37,7 @@
 
 		virtual CompoundStmt * mutate( CompoundStmt * compoundStmt );
+
+	  private:
+		std::list< Statement * > dtorStmts;
 	};
 
@@ -52,9 +55,10 @@
 			// a decision should have been made by the resolver, so ctor and init are not both non-NULL
 			assert( ! ctorInit->get_ctor() || ! ctorInit->get_init() );
-			if ( Expression * ctor = ctorInit->get_ctor() ) {
-				ExprStmt * ctorStmt = new ExprStmt( noLabels, ctor );
-				stmtsToAddAfter.push_back( ctorStmt );
+			if ( Statement * ctor = ctorInit->get_ctor() ) {
+				stmtsToAddAfter.push_back( ctor );
+				dtorStmts.push_front( ctorInit->get_dtor() );
 				objDecl->set_init( NULL );
 				ctorInit->set_ctor( NULL );
+				ctorInit->set_dtor( NULL );  // xxx - only destruct when constructing? Probably not?
 			} else if ( Initializer * init = ctorInit->get_init() ) {
 				objDecl->set_init( init );
@@ -70,25 +74,38 @@
 
 	CompoundStmt * FixInit::mutate( CompoundStmt * compoundStmt ) {
+		// mutate statements - this will also populate dtorStmts list
+		// don't want to dump all destructors when block is left,
+		// just the destructors associated with variables defined in this block
+		std::list< Statement * > oldDestructorStmts = dtorStmts;
+		dtorStmts = std::list<Statement *>();
+
+		compoundStmt = PolyMutator::mutate( compoundStmt );
 		std::list< Statement * > & statements = compoundStmt->get_kids();
-		for ( std::list< Statement * >::iterator it = statements.begin(); it != statements.end(); ) {
+		for ( std::list< Statement * >::iterator it = dtorStmts.begin(); it != dtorStmts.end(); ++it ) {
 			// remove if instrinsic destructor statement
 			// xxx - test user manually calling intrinsic functions - what happens?
 			if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( *it ) ) {
-				if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( exprStmt->get_expr() ) ) {
-					if ( VariableExpr * function = dynamic_cast< VariableExpr * >( appExpr->get_function() ) ) {
-						// check for Intrinsic only - don't want to remove all overridable dtors because autogenerated dtor
-						// will call all member dtors, and some members may have a user defined dtor.
-						if ( function->get_var()->get_name() == "^?{}" && function->get_var()->get_linkage() == LinkageSpec::Intrinsic ) {
-							statements.erase(it++);
-							continue;
-						} else {
-						}
-					}
+				ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( exprStmt->get_expr() );
+				assert( appExpr );
+				VariableExpr * function = dynamic_cast< VariableExpr * >( appExpr->get_function() );
+				assert( function );
+				// check for Intrinsic only - don't want to remove all overridable dtors because autogenerated dtor
+				// will call all member dtors, and some members may have a user defined dtor.
+				if ( function->get_var()->get_linkage() == LinkageSpec::Intrinsic ) {
+					// don't ned to call intrinsic dtor, because it does nothing
+					delete *it;
+				} else {
+					// non-intrinsic dtors must be called
+					statements.push_back( *it );
 				}
+			} else {
+				// could also be a compound statement with a loop, in the case of an array
+				statements.push_back( *it );
 			}
-			++it;
 		}
-		// mutate non-destructor statements
-		return PolyMutator::mutate( compoundStmt );
+		// TODO: adding to the end of a block isn't sufficient, since
+		// return/break/goto should trigger destructor when block is left.
+		dtorStmts = oldDestructorStmts;
+		return compoundStmt;
 	}
 
Index: src/InitTweak/RemoveInit.cc
===================================================================
--- src/InitTweak/RemoveInit.cc	(revision 5b40f300c07c8cd0b5d1720f42e535c1f4926bd5)
+++ src/InitTweak/RemoveInit.cc	(revision 5b2f5bb4b0269a726d7840b6f270858c3ff12d9a)
@@ -10,5 +10,5 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Rob Schluntz
-// Last Modified On : Tue Feb 09 15:12:29 2016
+// Last Modified On : Wed Mar 30 15:45:12 2016
 // Update Count     : 166
 //
@@ -72,11 +72,6 @@
 		virtual Declaration* mutate( TypedefDecl *typeDecl );
 
-		virtual CompoundStmt * mutate( CompoundStmt * compoundStmt );
-
 	  protected:
 		bool inFunction;
-
-		// to be added before block ends - use push_front so order is correct
-		std::list< Statement * > destructorStmts;
 	};
 
@@ -199,6 +194,22 @@
 					// call into makeArrayFunction from validate.cc to generate calls to ctor/dtor for each element of array
 					// TODO: walk initializer and generate appropriate copy ctor if element has initializer
-					SymTab::makeArrayFunction( NULL, new VariableExpr( objDecl ), at, "?{}", back_inserter( stmtsToAddAfter ) );
-					SymTab::makeArrayFunction( NULL, new VariableExpr( objDecl ), at, "^?{}", front_inserter( destructorStmts ), false );
+					std::list< Statement * > ctor;
+					std::list< Statement * > dtor;
+
+					SymTab::makeArrayFunction( NULL, new VariableExpr( objDecl ), at, "?{}", back_inserter( ctor ) );
+					SymTab::makeArrayFunction( NULL, new VariableExpr( objDecl ), at, "^?{}", front_inserter( dtor ), false );
+
+					// Currently makeArrayFunction produces a single Statement - a CompoundStmt
+					// which  wraps everything that needs to happen. As such, it's technically
+					// possible to use a Statement ** in the above calls, but this is inherently
+					// unsafe, so instead we take the slightly less efficient route, but will be
+					// immediately informed if somehow the above assumption is broken. In this case,
+					// we could always wrap the list of statements at this point with a CompoundStmt,
+					// but it seems reasonable at the moment for this to be done by makeArrayFunction
+					// itself
+					assert( ctor.size() == 1 );
+					assert( dtor.size() == 1 );
+
+					objDecl->set_init( new ConstructorInit( ctor.front(), dtor.front(), objDecl->get_init() ) );
 				} else {
 					// it's sufficient to attempt to call the ctor/dtor for the given object and its initializer
@@ -209,6 +220,7 @@
 					// if ctor does exist, want to use ctor expression instead of init
 					// push this decision to the resolver
-					objDecl->set_init( new ConstructorInit( ctor, objDecl->get_init() ) );
-					destructorStmts.push_front( new ExprStmt( noLabels, dtor ) );
+					ExprStmt * ctorStmt = new ExprStmt( noLabels, ctor );
+					ExprStmt * dtorStmt = new ExprStmt( noLabels, dtor );
+					objDecl->set_init( new ConstructorInit( ctorStmt, dtorStmt, objDecl->get_init() ) );
 				}
 			} else {
@@ -234,22 +246,4 @@
 	}
 
-	CompoundStmt * CtorDtor::mutate( CompoundStmt * compoundStmt ) {
-		// don't want to dump all destructors when block is left,
-		// just the destructors associated with variables defined in this block
-		std::list< Statement * > oldDestructorStmts = destructorStmts;
-		destructorStmts = std::list<Statement *>();
-
-		CompoundStmt * ret = PolyMutator::mutate( compoundStmt );
-		std::list< Statement * > &statements = ret->get_kids();
-		if ( ! destructorStmts.empty() ) {
-			// TODO: adding to the end of a block isn't sufficient, since
-			// return/break/goto should trigger destructor when block is left.
-			statements.splice( statements.end(), destructorStmts );
-		} // if
-
-		destructorStmts = oldDestructorStmts;
-		return ret;
-	}
-
 	// should not traverse into any of these declarations to find objects
 	// that need to be constructed or destructed
