Index: src/GenPoly/Box.cc
===================================================================
--- src/GenPoly/Box.cc	(revision b10c9959109272e0304123be8aaefa37571499cf)
+++ src/GenPoly/Box.cc	(revision 408d460b6eee7c0426d19f157e42b5879e8af665)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Rob Schluntz
-// Last Modified On : Fri Dec 18 14:53:08 2015
-// Update Count     : 217
+// Last Modified On : Fri Feb 05 12:23:10 2016
+// Update Count     : 280
 //
 
@@ -139,5 +139,5 @@
 			virtual Expression *mutate( OffsetofExpr *offsetofExpr );
 		};
-		
+
 		/// Replaces initialization of polymorphic values with alloca, declaration of dtype/ftype with appropriate void expression, and sizeof expressions of polymorphic types with the proper variable
 		class Pass3 : public PolyMutator {
@@ -178,5 +178,5 @@
 						seenIntrinsic = false; // break on this line when debugging for end of prelude
 					}
-					
+
 					*i = dynamic_cast< Declaration* >( (*i)->acceptMutator( mutator ) );
 					assert( *i );
@@ -286,5 +286,5 @@
 				}
 			}
-			
+
 			if ( functionDecl->get_statements() ) {		// empty routine body ?
 				doBeginScope();
@@ -320,5 +320,5 @@
 					findFunction( (*arg)->get_type(), functions, scopeTyVars, needsAdapter );
 				} // for
-				
+
 				AdapterMap & adapters = Pass1::adapters.top();
 				for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) {
@@ -373,5 +373,5 @@
 		Expression *Pass1::makeOffsetArray( StructInstType *ty ) {
 			std::list< Declaration* > &baseMembers = ty->get_baseStruct()->get_members();
-			
+
 			// make a new temporary array
 			Type *offsetType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
@@ -397,5 +397,5 @@
 			return new VariableExpr( arrayTemp );
 		}
-		
+
 		void Pass1::passTypeVars( ApplicationExpr *appExpr, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ) {
 			// pass size/align for type variables
@@ -493,5 +493,5 @@
 			}
 		}
-		
+
 		Type *Pass1::replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone ) {
 			if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
@@ -531,5 +531,7 @@
 			std::string adapterName = makeAdapterName( mangleName );
 
-			appExpr->get_args().push_front( appExpr->get_function() );
+			// cast adaptee to void (*)(), since it may have any type inside a polymorphic function
+			Type * adapteeType = new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) );
+			appExpr->get_args().push_front( new CastExpr( appExpr->get_function(), adapteeType ) );
 			appExpr->set_function( new NameExpr( adapterName ) );
 
@@ -559,14 +561,12 @@
 		}
 
+		/// cast parameters to polymorphic functions so that types are replaced with
+		/// void * if they are type parameters in the formal type.
+		/// this gets rid of warnings from gcc.
 		void addCast( Expression *&actual, Type *formal, const TyVarMap &tyVars ) {
-			Type *newType = formal->clone();
-			std::list< FunctionType *> functions;
-			// instead of functions needing adapters, this really ought to look for
-			// any function mentioning a polymorphic type
-			findAndReplaceFunction( newType, functions, tyVars, needsAdapter );
-			if ( ! functions.empty() ) {
+			Type * newType = formal->clone();
+			if ( getFunctionType( newType ) ) {
+				newType = ScrubTyVars::scrub( newType, tyVars );
 				actual = new CastExpr( actual, newType );
-			} else {
-				delete newType;
 			} // if
 		}
Index: src/GenPoly/FindFunction.cc
===================================================================
--- src/GenPoly/FindFunction.cc	(revision b10c9959109272e0304123be8aaefa37571499cf)
+++ src/GenPoly/FindFunction.cc	(revision 408d460b6eee7c0426d19f157e42b5879e8af665)
@@ -5,11 +5,11 @@
 // file "LICENCE" distributed with Cforall.
 //
-// FindFunction.cc -- 
+// FindFunction.cc --
 //
 // Author           : Richard C. Bilson
 // Created On       : Mon May 18 07:44:20 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Tue May 19 07:35:48 2015
-// Update Count     : 1
+// Last Modified By : Rob Schluntz
+// Last Modified On : Fri Feb 05 12:22:20 2016
+// Update Count     : 6
 //
 
@@ -19,9 +19,11 @@
 #include "SynTree/Visitor.h"
 
+#include "ScrubTyVars.h"
+
 namespace GenPoly {
 	class FindFunction : public Mutator {
 	  public:
 		FindFunction( std::list< FunctionType* > &functions, const TyVarMap &tyVars, bool replaceMode, FindFunctionPredicate predicate );
-  
+
 		virtual Type *mutate( FunctionType *functionType );
 		virtual Type *mutate( PointerType *pointerType );
@@ -66,5 +68,6 @@
 			functions.push_back( functionType );
 			if ( replaceMode ) {
-				ret = new FunctionType( Type::Qualifiers(), true );
+				// replace type parameters in function type with void*
+				ret = ScrubTyVars::scrub( functionType->clone(), tyVars );
 			} // if
 		} // if
Index: src/libcfa/algorithm
===================================================================
--- src/libcfa/algorithm	(revision b10c9959109272e0304123be8aaefa37571499cf)
+++ src/libcfa/algorithm	(revision 408d460b6eee7c0426d19f157e42b5879e8af665)
@@ -5,5 +5,5 @@
 // file "LICENCE" distributed with Cforall.
 //
-// alorgithm -- 
+// alorgithm --
 //
 // Author           : Peter A. Buhr
@@ -16,8 +16,8 @@
 //---------------------------------------
 
-forall( type T | { int ?<?( T, T ); } )
+forall( type T | { int ?<?( const T, const T ); } )
 T min( const T t1, const T t2 );
 
-forall( type T | { int ?>?( T, T ); } )
+forall( type T | { int ?>?( const T, const T ); } )
 T max( const T t1, const T t2 );
 
Index: src/libcfa/algorithm.c
===================================================================
--- src/libcfa/algorithm.c	(revision b10c9959109272e0304123be8aaefa37571499cf)
+++ src/libcfa/algorithm.c	(revision 408d460b6eee7c0426d19f157e42b5879e8af665)
@@ -5,21 +5,21 @@
 // file "LICENCE" distributed with Cforall.
 //
-// algorithm.c -- 
+// algorithm.c --
 //
 // Author           : Peter A. Buhr
 // Created On       : Thu Jan 28 17:10:29 2016
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Feb  1 13:42:05 2016
-// Update Count     : 52
+// Last Modified By : Rob Schluntz
+// Last Modified On : Thu Feb 04 17:19:12 2016
+// Update Count     : 54
 //
 
 #include "algorithm"
 
-forall( type T | { int ?<?( T, T ); } )
+forall( type T | { int ?<?( const T, const T ); } )
 T min( const T t1, const T t2 ) {
 	return t1 < t2 ? t1 : t2;
 } // min
 
-forall( type T | { int ?>?( T, T ); } )
+forall( type T | { int ?>?( const T, const T ); } )
 T max( const T t1, const T t2 ) {
 	return t1 > t2 ? t1 : t2;
