Index: src/GenPoly/Specialize.cc
===================================================================
--- src/GenPoly/Specialize.cc	(revision 05d472781f65644ac06288649bee186de41bf983)
+++ src/GenPoly/Specialize.cc	(revision 421edab1bdb7fa75f18e1afc4cd938f55f13d710)
@@ -5,11 +5,11 @@
 // file "LICENCE" distributed with Cforall.
 //
-// Specialize.cc -- 
+// Specialize.cc --
 //
 // Author           : Richard C. Bilson
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Rob Schluntz
-// Last Modified On : Tue Sep 22 14:04:13 2015
-// Update Count     : 15
+// Last Modified On : Wed Jan 20 12:40:33 2016
+// Update Count     : 18
 //
 
@@ -140,6 +140,7 @@
 		return new AddressExpr( new VariableExpr( thunkFunc ) );
 	}
-	
+
 	Expression * Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ) {
+		assert( ! actual->get_results().empty() );
 		if ( needsSpecialization( formalType, actual->get_results().front(), env ) ) {
 			FunctionType *funType;
@@ -198,4 +199,8 @@
 	Expression * Specialize::mutate( CastExpr *castExpr ) {
 		castExpr->get_arg()->acceptMutator( *this );
+		if ( castExpr->get_results().empty() ) {
+			// can't specialize if we don't have a return value
+			return castExpr;
+		}
 		Expression *specialized = doSpecialization( castExpr->get_results().front(), castExpr->get_arg() );
 		if ( specialized != castExpr->get_arg() ) {
