Index: src/GenPoly/Lvalue.cc
===================================================================
--- src/GenPoly/Lvalue.cc	(revision 4d6d62ed4859b907bfb967784da082be0112c77a)
+++ src/GenPoly/Lvalue.cc	(revision 6b8c4a8c388b7ab43ded2b96957e296c130305ab)
@@ -403,5 +403,5 @@
 					ret = new AddressExpr( ret );
 				}
-				if ( srcType->get_lvalue() && srcType->get_qualifiers() != strict_dynamic_cast<ReferenceType *>( destType )->base->get_qualifiers() ) {
+				if ( srcType->get_lvalue() && ! ResolvExpr::typesCompatible( srcType, strict_dynamic_cast<ReferenceType *>( destType )->base, SymTab::Indexer() ) ) {
 					// must keep cast if cast-to type is different from the actual type
 					castExpr->arg = ret;
