Index: src/CodeGen/CodeGenerator.cc
===================================================================
--- src/CodeGen/CodeGenerator.cc	(revision 05d472781f65644ac06288649bee186de41bf983)
+++ src/CodeGen/CodeGenerator.cc	(revision 421edab1bdb7fa75f18e1afc4cd938f55f13d710)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Rob Schluntz
-// Last Modified On : Thu Sep 17 15:24:08 2015
-// Update Count     : 231
+// Last Modified On : Wed Jan 20 12:54:50 2016
+// Update Count     : 241
 //
 
@@ -392,20 +392,19 @@
 
 	void CodeGenerator::visit( CastExpr *castExpr ) {
-		// if the cast is to an lvalue type, then the cast
-		// should be dropped, since the result of a cast is
-		// never an lvalue in C
-		if ( castExpr->get_results().front()->get_isLvalue() ) {
-			castExpr->get_arg()->accept( *this );
-		} else {
-			output << "((";
-			if ( castExpr->get_results().empty() ) {
-				output << "void" ;
-			} else {
-				output << genType( castExpr->get_results().front(), "" );
-			} // if
+		output << "(";
+		if ( castExpr->get_results().empty() ) {
+			output << "(void)" ;
+		} else if ( ! castExpr->get_results().front()->get_isLvalue() ) {
+			// at least one result type of cast, but not an lvalue
+			output << "(";
+			output << genType( castExpr->get_results().front(), "" );
 			output << ")";
-			castExpr->get_arg()->accept( *this );
-			output << ")";			
+		} else {
+			// otherwise, the cast is to an lvalue type, so the cast
+			// should be dropped, since the result of a cast is
+			// never an lvalue in C
 		}
+		castExpr->get_arg()->accept( *this );
+		output << ")";
 	}
   
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() ) {
