Index: src/GenPoly/InstantiateGeneric.cc
===================================================================
--- src/GenPoly/InstantiateGeneric.cc	(revision a3323db19a224d716f0e5bae4165484cef7febdb)
+++ src/GenPoly/InstantiateGeneric.cc	(revision 27aca84c89a0c7286b8f204457ed8b73e6f31156)
@@ -496,4 +496,5 @@
 	Expression * FixDtypeStatic::fixMemberExpr( AggrInst * inst, MemberExpr * memberExpr ) {
 		// need to cast dtype-static member expressions to their actual type before that type is erased.
+		// NOTE: the casts here have the third argument (isGenerated) set to false so that these casts persist until Box, where they are needed.
 		auto & baseParams = *inst->get_baseParameters();
 		if ( isDtypeStatic( baseParams ) ) {
@@ -515,5 +516,5 @@
 					// Note: this currently creates more temporaries than is strictly necessary, since it does not check for duplicate uses of the same member expression.
 					static UniqueName tmpNamer( "_dtype_static_member_" );
-					Expression * init = new CastExpr( new AddressExpr( memberExpr ), new PointerType( Type::Qualifiers(), concType->clone() ) );
+					Expression * init = new CastExpr( new AddressExpr( memberExpr ), new PointerType( Type::Qualifiers(), concType->clone() ), false );
 					ObjectDecl * tmp = ObjectDecl::newObject( tmpNamer.newName(), new ReferenceType( Type::Qualifiers(), concType ), new SingleInit( init ) );
 					stmtsToAddBefore.push_back( new DeclStmt( tmp ) );
@@ -521,5 +522,5 @@
 				} else {
 					// can simply add a cast to actual type
-					return new CastExpr( memberExpr, concType );
+					return new CastExpr( memberExpr, concType, false );
 				}
 			}
