Index: src/ResolvExpr/ConversionCost.cc
===================================================================
--- src/ResolvExpr/ConversionCost.cc	(revision 7e003011cac72e307c02d183bca9cbd4a982d69b)
+++ src/ResolvExpr/ConversionCost.cc	(revision 6b9b04774733cb2fbec40e4c126e7097d99a9290)
@@ -57,4 +57,7 @@
 		} else if ( dynamic_cast< VoidType* >( dest ) ) {
 			return Cost( 0, 0, 1 );
+		} else if ( ReferenceType * refType = dynamic_cast< ReferenceType * > ( dest ) ) {
+			// std::cerr << "conversionCost: dest is reference" << std::endl;
+			return convertToReferenceCost( src, refType, indexer, env );
 		} else {
 			ConversionCost converter( dest, indexer, env );
@@ -66,4 +69,45 @@
 			} // if
 		} // if
+	}
+
+	Cost convertToReferenceCost( Type * src, ReferenceType * dest, const SymTab::Indexer & indexer, const TypeEnvironment & env ) {
+		// std::cerr << "convert to reference cost..." << std::endl;
+		if ( ReferenceType *srcAsRef = dynamic_cast< ReferenceType * >( src ) ) { // pointer-like conversions between references
+			// std::cerr << "converting between references" << std::endl;
+			if ( srcAsRef->get_base()->get_qualifiers() <= dest->get_base()->get_qualifiers() && typesCompatibleIgnoreQualifiers( srcAsRef->get_base(), dest->get_base(), indexer, env ) ) {
+				return Cost( 0, 0, 1 );
+			} else {  // xxx - this discards reference qualifiers from consideration -- reducing qualifiers is a safe conversion; is this right?
+				int assignResult = ptrsAssignable( srcAsRef->get_base(), dest->get_base(), env );
+				if ( assignResult < 0 ) {
+					return Cost( 0, 0, 1 );
+				} else if ( assignResult > 0 ) {
+					return Cost( 1, 0, 0 );
+				} // if
+			} // if
+		} else if ( typesCompatibleIgnoreQualifiers( src, dest->get_base(), indexer, env ) ) {
+			// std::cerr << "converting compatible base type" << std::endl;
+			if ( src->get_lvalue() ) {
+				// std::cerr << "lvalue to reference conversion" << std::endl;
+				// lvalue-to-reference conversion:  cv lvalue T => cv T &
+				if ( src->get_qualifiers() == dest->get_base()->get_qualifiers() ) {
+					return Cost( 0, 0, 1 ); // cost needs to be non-zero to add cast
+				} if ( src->get_qualifiers() < dest->get_base()->get_qualifiers() ) {
+					return Cost( 0, 0, 2 ); // cost needs to be higher than previous cast to differentiate adding qualifiers vs. keeping same
+				} else {
+					return Cost( 1, 0, 0 );
+				}
+			} else if ( dest->get_base()->get_const() ) {
+				// std::cerr << "rvalue to const ref conversion" << std::endl;
+				// rvalue-to-const-reference conversion: T => const T &
+				return Cost( 0, 0, 1 );
+			} else {
+				// std::cerr << "rvalue to non-const reference conversion" << std::endl;
+				// rvalue-to-reference conversion: T => T &
+				return Cost( 1, 0, 0 );
+			}
+		} else {
+			// std::cerr << "attempting to convert from incompatible base type -- fail" << std::endl;
+		}
+		return Cost::infinity;
 	}
 
@@ -173,5 +217,5 @@
 			if ( pointerType->get_base()->get_qualifiers() <= destAsPtr->get_base()->get_qualifiers() && typesCompatibleIgnoreQualifiers( pointerType->get_base(), destAsPtr->get_base(), indexer, env ) ) {
 				cost = Cost( 0, 0, 1 );
-			} else {
+			} else {  // xxx - this discards pointer qualifiers from consideration -- reducing qualifiers is a safe conversion; is this right?
 				int assignResult = ptrsAssignable( pointerType->get_base(), destAsPtr->get_base(), env );
 				if ( assignResult < 0 ) {
@@ -187,4 +231,14 @@
 
 	void ConversionCost::visit(__attribute((unused)) ArrayType *arrayType) {}
+
+	void ConversionCost::visit(ReferenceType *refType) {
+		// Note: dest can never be a reference, since it would have been caught in an earlier check
+		assert( ! dynamic_cast< ReferenceType * >( dest ) );
+		// convert reference to rvalue: cv T1 & => T2
+		// recursively compute conversion cost from T1 to T2.
+		// cv can be safely dropped because of 'implicit dereference' behavior.
+		refType->get_base()->accept( *this );
+	}
+
 	void ConversionCost::visit(__attribute((unused)) FunctionType *functionType) {}
 
@@ -208,5 +262,5 @@
 		static Type::Qualifiers q;
 		static BasicType integer( q, BasicType::SignedInt );
-		integer.accept( *this );
+		integer.accept( *this );  // safe if dest >= int
 		if ( cost < Cost( 1, 0, 0 ) ) {
 			cost.incSafe();
