Index: src/ResolvExpr/Cost.h
===================================================================
--- src/ResolvExpr/Cost.h	(revision d16855887abd5ffcdf4d9cbfeab1b37fdce4d49a)
+++ src/ResolvExpr/Cost.h	(revision 17f22e78472d685cb5d6dd6dbebfb99c0f9ba439)
@@ -57,4 +57,5 @@
 
 	inline Cost & Cost::incUnsafe( int inc ) {
+		if ( *this == infinity ) return *this;
 		unsafeCost += inc;
 		return *this;
@@ -62,4 +63,5 @@
 
 	inline Cost & Cost::incPoly( int inc ) {
+		if ( *this == infinity ) return *this;
 		polyCost += inc;
 		return *this;
@@ -67,4 +69,5 @@
 
 	inline Cost & Cost::incSafe( int inc ) {
+		if ( *this == infinity ) return *this;
 		safeCost += inc;
 		return *this;
@@ -72,4 +75,5 @@
 
 	inline Cost & Cost::incReference( int inc ) {
+		if ( *this == infinity ) return *this;
 		referenceCost += inc;
 		return *this;
@@ -77,12 +81,19 @@
 
 	inline Cost Cost::operator+( const Cost &other ) const {
+		if ( *this == infinity || other == infinity ) return infinity;
 		return Cost( unsafeCost + other.unsafeCost, polyCost + other.polyCost, safeCost + other.safeCost, referenceCost + other.referenceCost );
 	}
 
 	inline Cost Cost::operator-( const Cost &other ) const {
+		if ( *this == infinity || other == infinity ) return infinity;
 		return Cost( unsafeCost - other.unsafeCost, polyCost - other.polyCost, safeCost - other.safeCost, referenceCost - other.referenceCost );
 	}
 
 	inline Cost &Cost::operator+=( const Cost &other ) {
+		if ( *this == infinity ) return *this;
+		if ( other == infinity ) {
+			*this = infinity;
+			return *this;
+		}
 		unsafeCost += other.unsafeCost;
 		polyCost += other.polyCost;
