Index: src/ResolvExpr/Resolver.cc
===================================================================
--- src/ResolvExpr/Resolver.cc	(revision 10a7775d07dcc9d19f88786e6be9a198720e9cac)
+++ src/ResolvExpr/Resolver.cc	(revision 64071c2ad8eac1915b692988a8dc0d8e9d7cb8da)
@@ -516,13 +516,13 @@
 
 	void Resolver::visit( ImplicitCtorDtorStmt * impCtorDtorStmt ) {
-		// this code is fairly gross. If VariableExpr didn't have its own results list then this could be cleaned up a bit
-		// by remembering the ObjectDecl in the ImplicitCtorDtorStmt and changing the ObjectDecl's type temporarily, but currently
-		// VariableExprs have their own type list which is manipulated in AlternativeFinder (e.g. in inferRecursive).
-
-		// before resolving ctor/dtor, need to remove type qualifiers from the first argument (the object being constructed)
+		// before resolving ctor/dtor, need to remove type qualifiers from the first argument (the object being constructed).
+		// Do this through a cast expression to greatly simplify the code.
 		Expression * callExpr = InitTweak::getCtorDtorCall( impCtorDtorStmt );
 		assert( callExpr );
-		Expression * constructee = InitTweak::getCallArg( callExpr, 0 );
+		Expression *& constructee = InitTweak::getCallArg( callExpr, 0 );
 		Type * type = 0;
+
+		// need to find the type of the first argument, which is unfortunately not uniform since array construction
+		// includes an untyped '+' expression.
 		if ( UntypedExpr * plusExpr = dynamic_cast< UntypedExpr * >( constructee ) ) {
 			// constructee is <array>+<index>
@@ -531,6 +531,5 @@
 			assert( dynamic_cast< VariableExpr * >( arr ) );
 			assert( arr && arr->get_results().size() == 1 );
-			type = InitTweak::getPointerBase( arr->get_results().front() );
-			assert( type );
+			type = arr->get_results().front()->clone();
 		} else {
 			// otherwise, constructing a plain object, which means the object's address is being taken.
@@ -539,50 +538,21 @@
 			assert( constructee->get_results().size() == 1 );
 			AddressExpr * addrExpr = dynamic_cast< AddressExpr * > ( constructee );
-			assert( addrExpr );
-			VariableExpr * varExpr = dynamic_cast< VariableExpr * >( addrExpr->get_arg() );
-			assert( varExpr && varExpr->get_results().size() == 1 );
-			type = varExpr->get_results().front();
-		}
-		// remember qualifiers so they can be replaced
-		Type::Qualifiers qualifiers = type->get_qualifiers();
-
+			assert( addrExpr && addrExpr->get_results().size() == 1);
+			type = addrExpr->get_results().front()->clone();
+		}
+		// cast to T* with qualifiers removed.
 		// unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument
 		// must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever
 		// remove lvalue as a qualifier, this can change to
 		//   type->get_qualifiers() = Type::Qualifiers();
-		type->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, true);
+		Type * base = InitTweak::getPointerBase( type );
+		assert( base );
+		base->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, true);
+		// if pointer has lvalue qualifier, cast won't appear in output
+		type->set_isLvalue( false );
+		constructee = new CastExpr( constructee, type );
 
 		// finally, resolve the ctor/dtor
 		impCtorDtorStmt->get_callStmt()->accept( *this );
-
-		// reset type qualifiers, but first need to figure out where everything is again
-		// because the expressions are often changed by the resolver.
-		callExpr = InitTweak::getCtorDtorCall( impCtorDtorStmt );
-		assert( callExpr );
-		constructee = InitTweak::getCallArg( callExpr, 0 );
-		if ( ApplicationExpr * plusExpr = dynamic_cast< ApplicationExpr * >( constructee ) ) {
-			// constructee is <array>+<index>
-			// get Variable <array>, then get the base type of the VariableExpr - this is the type that needs to be fixed
-			Expression * arr = InitTweak::getCallArg( plusExpr, 0 );
-			assert( dynamic_cast< VariableExpr * >( arr ) );
-			assert( arr && arr->get_results().size() == 1 );
-			type = InitTweak::getPointerBase( arr->get_results().front() );
-			assert( type );
-			type->get_qualifiers() = qualifiers;
-		} else {
-			// otherwise constructing a plain object
-			// replace qualifiers on AddressExpr and on inner VariableExpr
-			assert( constructee->get_results().size() == 1 );
-			AddressExpr * addrExpr = dynamic_cast< AddressExpr * > ( constructee );
-			assert( addrExpr );
-			type = InitTweak::getPointerBase( addrExpr->get_results().front() );
-			assert( type );
-			type->get_qualifiers() = qualifiers;
-
-			VariableExpr * varExpr = dynamic_cast< VariableExpr * >( addrExpr->get_arg() );
-			assert( varExpr && varExpr->get_results().size() == 1 );
-			type = varExpr->get_results().front();
-			type->get_qualifiers() = qualifiers;
-		}
 	}
 } // namespace ResolvExpr
