Index: src/ResolvExpr/CandidateFinder.cpp
===================================================================
--- src/ResolvExpr/CandidateFinder.cpp	(revision 7ff3e5224d41942a97b813aec3db3d1126db4898)
+++ src/ResolvExpr/CandidateFinder.cpp	(revision 13d33a758fd4097ca7b39a0687501ef7853332a1)
@@ -1473,5 +1473,5 @@
 					// unification run for side-effects
 					unify( toType, cand->expr->result, env, need, have, open, symtab );
-					Cost thisCost = castCost( cand->expr->result, toType, cand->expr->get_lvalue(),
+					Cost thisCost = computeConversionCost( cand->expr->result, toType, cand->expr->get_lvalue(),
 							symtab, env );
 
@@ -1483,5 +1483,5 @@
 								initExpr->location, restructureCast( cand->expr, toType ),
 								initAlt.designation },
-							copy( cand->env ), move( open ), move( need ), cand->cost, thisCost );
+							move(env), move( open ), move( need ), cand->cost, thisCost );
 						inferParameters( newCand, matches );
 					}
Index: src/ResolvExpr/Unify.cc
===================================================================
--- src/ResolvExpr/Unify.cc	(revision 7ff3e5224d41942a97b813aec3db3d1126db4898)
+++ src/ResolvExpr/Unify.cc	(revision 13d33a758fd4097ca7b39a0687501ef7853332a1)
@@ -791,6 +791,9 @@
 			for ( const ast::DeclWithType * d : src ) {
 				ast::Pass<TtypeExpander_new> expander{ env };
-				d = d->accept( expander );
-				auto types = flatten( d->get_type() );
+				// TtypeExpander pass is impure (may mutate nodes in place)
+				// need to make nodes shared to prevent accidental mutation
+				ast::ptr<ast::DeclWithType> dc = d;
+				dc = dc->accept( expander );
+				auto types = flatten( dc->get_type() );
 				for ( ast::ptr< ast::Type > & t : types ) {
 					// outermost const, volatile, _Atomic qualifiers in parameters should not play
@@ -801,5 +804,5 @@
 					// requirements than a non-mutex function
 					remove_qualifiers( t, ast::CV::Const | ast::CV::Volatile | ast::CV::Atomic );
-					dst.emplace_back( new ast::ObjectDecl{ d->location, "", t } );
+					dst.emplace_back( new ast::ObjectDecl{ dc->location, "", t } );
 				}
 			}
@@ -1110,6 +1113,9 @@
 
 			ast::Pass<TtypeExpander_new> expander{ tenv };
-			const ast::Type * flat = tuple->accept( expander );
-			const ast::Type * flat2 = tuple2->accept( expander );
+
+			ast::ptr<ast::TupleType> tuplec = tuple;
+			ast::ptr<ast::TupleType> tuple2c = tuple2;
+			const ast::Type * flat = tuplec->accept( expander );
+			const ast::Type * flat2 = tuple2c->accept( expander );
 
 			auto types = flatten( flat );
