diff -ur ginac-1.5.1/ginac/clifford.cpp ginac-1.5.1-new/ginac/clifford.cpp
--- ginac-1.5.1/ginac/clifford.cpp	2009-02-17 13:39:22 +0000
+++ ginac-1.5.1-new/ginac/clifford.cpp	2009-04-12 10:24:39 +0100
@@ -1291,11 +1291,11 @@
 	if (algebraic) // check if algebraic method is applicable
 		for (unsigned int i = 0; i < D; i++) 
 			if (pow(c.subs(mu == i, subs_options::no_pattern), 2).is_zero() 
-				or (not is_a<numeric>(pow(c.subs(mu == i, subs_options::no_pattern), 2))))
+				|| (! is_a<numeric>(pow(c.subs(mu == i, subs_options::no_pattern), 2))))
 				algebraic = false;
 	lst V; 
 	ex v0 = remove_dirac_ONE(canonicalize_clifford(e+clifford_prime(e)).normal())/2;
-	if (not v0.is_zero())
+	if (! v0.is_zero())
 		V.append(v0);
 	ex e1 = canonicalize_clifford(e - v0 * dirac_ONE(ex_to<clifford>(c).get_representation_label())); 
 	if (algebraic) {
@@ -1312,7 +1312,7 @@
 			e1 = canonicalize_clifford(expand_dummy_sum(e, true));
 			V.remove_all();
 			v0 = remove_dirac_ONE(canonicalize_clifford(e1+clifford_prime(e1)).normal())/2;
-			if (not v0.is_zero()) {
+			if (! v0.is_zero()) {
 				V.append(v0);
 				e1 = canonicalize_clifford(e1 - v0 * dirac_ONE(ex_to<clifford>(c).get_representation_label())); 
 			}
diff -ur ginac-1.5.1/ginac/ex.h ginac-1.5.1-new/ginac/ex.h
--- ginac-1.5.1/ginac/ex.h	2009-02-17 13:39:22 +0000
+++ ginac-1.5.1-new/ginac/ex.h	2009-04-15 18:53:09 +0100
@@ -57,6 +57,8 @@
 class const_preorder_iterator;
 class const_postorder_iterator;
 
+class ex;
+extern const ex _ex0;
 
 /** Lightweight wrapper for GiNaC's symbolic objects.  It holds a pointer to
  *  the other object in order to do garbage collection by the method of
@@ -204,7 +206,7 @@
 	// comparison
 	int compare(const ex & other) const;
 	bool is_equal(const ex & other) const;
-	bool is_zero() const { extern const ex _ex0; return is_equal(_ex0); }
+	bool is_zero() const { return is_equal(_ex0); }
 	bool is_zero_matrix() const;
 	
 	// symmetry
diff -ur ginac-1.5.1/ginac/exprseq.cpp ginac-1.5.1-new/ginac/exprseq.cpp
--- ginac-1.5.1/ginac/exprseq.cpp	2009-02-17 13:39:22 +0000
+++ ginac-1.5.1-new/ginac/exprseq.cpp	2009-04-15 21:58:16 +0100
@@ -37,4 +37,6 @@
 		return inherited::info(inf);
 }
 
+basic* dummy_func(void) { return new exprseq(); }
+
 } // namespace GiNaC
diff -ur ginac-1.5.1/ginac/factor.cpp ginac-1.5.1-new/ginac/factor.cpp
--- ginac-1.5.1/ginac/factor.cpp	2009-02-25 11:46:17 +0000
+++ ginac-1.5.1-new/ginac/factor.cpp	2009-04-15 23:42:31 +0100
@@ -694,7 +694,7 @@
 		mvec::iterator i = m.begin() + col;
 		for ( size_t rc=0; rc<r; ++rc ) {
 			*i = *i * x;
-			i += c;
+			if (rc<(r-1)) i += c;
 		}
 	}
 	void sub_col(size_t col1, size_t col2, const cl_MI fac)
@@ -703,8 +703,10 @@
 		mvec::iterator i2 = m.begin() + col2;
 		for ( size_t rc=0; rc<r; ++rc ) {
 			*i1 = *i1 - *i2 * fac;
-			i1 += c;
-			i2 += c;
+			if (rc<(r-1)) {
+				i1 += c;
+				i2 += c;
+			}
 		}
 	}
 	void switch_col(size_t col1, size_t col2)
@@ -714,8 +716,10 @@
 		mvec::iterator i2 = m.begin() + col2;
 		for ( size_t rc=0; rc<r; ++rc ) {
 			buf = *i1; *i1 = *i2; *i2 = buf;
-			i1 += c;
-			i2 += c;
+			if (rc<(r-1)) {
+				i1 += c;
+				i2 += c;
+			}
 		}
 	}
 	void mul_row(size_t row, const cl_MI x)
diff -ur ginac-1.5.1/ginac/function.cpp ginac-1.5.1-new/ginac/function.cpp
--- ginac-1.5.1/ginac/function.cpp	2009-02-25 11:47:19 +0000
+++ ginac-1.5.1-new/ginac/function.cpp	2009-04-12 11:06:59 +0100
@@ -1794,7 +1794,7 @@
 	
 	// No derivative defined? Then return abstract derivative object
 	if (opt.power_f == NULL)
-		return (new power::power(*this, power_param))->setflag(status_flags::dynallocated |
+		return (new GiNaC::power(*this, power_param))->setflag(status_flags::dynallocated |
 	                                               status_flags::evaluated);
 
 	current_serial = serial;
diff -ur ginac-1.5.1/ginac/inifcns_nstdsums.cpp ginac-1.5.1-new/ginac/inifcns_nstdsums.cpp
--- ginac-1.5.1/ginac/inifcns_nstdsums.cpp	2009-02-17 13:39:22 +0000
+++ ginac-1.5.1-new/ginac/inifcns_nstdsums.cpp	2009-04-16 22:30:30 +0100
@@ -569,9 +569,10 @@
 
 			Gparameter newa;
 			Gparameter::const_iterator it2 = short_a.begin();
-			for (--it2; it2 != it;) {
-				++it2;
+			while (it2 <= it) {
 				newa.push_back(*it2);
+				if (it2 < it) ++it2;
+				else break;
 			}
 			newa.push_back(a[0]);
 			++it2;
@@ -658,7 +659,7 @@
 			++trailing_zeros;
 		}
 	}
-	return ++lastnonzero;
+	return (lastnonzero != a.end() ? ++lastnonzero : lastnonzero);
 }
 
 
diff -ur ginac-1.5.1/ginac/ncmul.cpp ginac-1.5.1-new/ginac/ncmul.cpp
--- ginac-1.5.1/ginac/ncmul.cpp	2009-02-17 13:39:22 +0000
+++ ginac-1.5.1-new/ginac/ncmul.cpp	2009-04-15 23:14:00 +0100
@@ -340,7 +340,7 @@
 
 	// determine return types
 	unsignedvector rettypes;
-	rettypes.reserve(assocseq.size());
+	rettypes.resize(assocseq.size());
 	size_t i = 0;
 	size_t count_commutative=0;
 	size_t count_noncommutative=0;
diff -ur ginac-1.5.1/ginac/parser/parse_binop_rhs.cpp ginac-1.5.1-new/ginac/parser/parse_binop_rhs.cpp
--- ginac-1.5.1/ginac/parser/parse_binop_rhs.cpp	2009-02-17 13:39:22 +0000
+++ ginac-1.5.1-new/ginac/parser/parse_binop_rhs.cpp	2009-04-15 22:08:40 +0100
@@ -114,7 +114,7 @@
 	}
 }
 
-extern numeric* _num_1_p;
+extern const numeric* _num_1_p;
 
 static ex make_minus_expr(const exvector& args)
 {
@@ -151,12 +151,12 @@
 		case '^':
 			if (args.size() != 2)
 				throw std::invalid_argument(
-						std::string(__func__) 
+						std::string("make_binop_expr") 
 						+ ": power should have exactly 2 operands");
 			return pow(args[0], args[1]);
 		default:
 			throw std::invalid_argument(
-					std::string(__func__) 
+					std::string("make_binop_expr") 
 					+ ": invalid binary operation: " 
 					+ char(binop));
 	}
diff -ur ginac-1.5.1/ginac/parser/parser.cpp ginac-1.5.1-new/ginac/parser/parser.cpp
--- ginac-1.5.1/ginac/parser/parser.cpp	2009-02-17 13:39:22 +0000
+++ ginac-1.5.1-new/ginac/parser/parser.cpp	2009-04-15 20:59:47 +0100
@@ -82,7 +82,7 @@
 }
 
 extern numeric* _num_1_p;
-extern ex _ex0;
+extern const ex _ex0;
 
 /// unary_expr: [+-] expression
 ex parser::parse_unary_expr()
diff -ur ginac-1.5.1/ginac/polynomial/collect_vargs.cpp ginac-1.5.1-new/ginac/polynomial/collect_vargs.cpp
--- ginac-1.5.1/ginac/polynomial/collect_vargs.cpp	2009-02-17 13:39:22 +0000
+++ ginac-1.5.1-new/ginac/polynomial/collect_vargs.cpp	2009-04-12 11:58:00 +0100
@@ -69,7 +69,7 @@
 };
 
 template<typename T, typename CoeffCMP>
-static struct compare_terms<T, CoeffCMP>
+static compare_terms<T, CoeffCMP>
 make_compare_terms(const T& dummy, const CoeffCMP& coeff_cmp)
 {
 	return compare_terms<T, CoeffCMP>(coeff_cmp);
diff -ur ginac-1.5.1/ginac/polynomial/debug.h ginac-1.5.1-new/ginac/polynomial/debug.h
--- ginac-1.5.1/ginac/polynomial/debug.h	2009-02-17 13:39:22 +0000
+++ ginac-1.5.1-new/ginac/polynomial/debug.h	2009-04-12 11:51:45 +0100
@@ -30,8 +30,8 @@
 #include <stdexcept>
 #include <string>
 
-#define DEBUG_PREFIX __func__ << ':' << __LINE__ << ": "
-#define EXCEPTION_PREFIX std::string(__func__) + std::string(": ") +
+#define DEBUG_PREFIX __FILE__ << ':' << __LINE__ << ": "
+#define EXCEPTION_PREFIX std::string(__FILE__) + std::string(": ") +
 
 #define Dout2(stream, msg)                                    \
 do {                                                          \
diff -ur ginac-1.5.1/ginac/polynomial/primes_factory.h ginac-1.5.1-new/ginac/polynomial/primes_factory.h
--- ginac-1.5.1/ginac/polynomial/primes_factory.h	2009-02-17 13:39:22 +0000
+++ ginac-1.5.1-new/ginac/polynomial/primes_factory.h	2009-04-15 18:43:42 +0100
@@ -47,7 +47,7 @@
 	// or even numeric. Eventually this will be fixed).
 	cln::cl_I last;
 	// This ensures coefficients are immediate.
-	static const int immediate_bits = 8*sizeof(void *) - __alignof__(void *);
+	static const int immediate_bits = 8*sizeof(void *) - __alignof(void *);
 	static const long opt_hint = (1L << (immediate_bits >> 1)) - 1;
 public:
 	primes_factory()
diff -ur ginac-1.5.1/ginac/polynomial/primpart_content.cpp ginac-1.5.1-new/ginac/polynomial/primpart_content.cpp
--- ginac-1.5.1/ginac/polynomial/primpart_content.cpp	2009-02-17 13:39:22 +0000
+++ ginac-1.5.1-new/ginac/polynomial/primpart_content.cpp	2009-04-15 18:44:40 +0100
@@ -86,7 +86,7 @@
 	for (i = ec.rbegin(); i != ec.rend(); ++i) {
 		ex tmp(0);
 		if (!divide_in_z_p(i->second, g, tmp, mainvar, p))
-			throw std::logic_error(std::string(__func__) +
+			throw std::logic_error(std::string(__FILE__) +
 					": bogus division failure");
 		i->second = tmp;
 	}
diff -ur ginac-1.5.1/ginac/symmetry.cpp ginac-1.5.1-new/ginac/symmetry.cpp
--- ginac-1.5.1/ginac/symmetry.cpp	2009-02-25 11:46:37 +0000
+++ ginac-1.5.1-new/ginac/symmetry.cpp	2009-04-12 11:11:05 +0100
@@ -160,7 +160,7 @@
 		return 1;
 	if (this_size < that_size)
 		return -1;
-	typedef std::set<unsigned>::iterator set_it;
+	typedef std::set<unsigned>::const_iterator set_it;
 	set_it end = indices.end();
 	for (set_it i=indices.begin(),j=othersymm.indices.begin(); i!=end; ++i,++j) {
 		if(*i < *j)
diff -ur ginac-1.5.1/ginac/utils.h ginac-1.5.1-new/ginac/utils.h
--- ginac-1.5.1/ginac/utils.h	2009-02-17 13:39:22 +0000
+++ ginac-1.5.1-new/ginac/utils.h	2009-04-15 23:02:04 +0100
@@ -128,7 +128,7 @@
 				sign = -sign;
 			} else if (!(*other < *i))
 				return 0;
-			--i; --other;
+			--i; if (other != first) --other;
 		}
 		if (!swapped)
 			return sign;
@@ -181,7 +181,7 @@
 				sign = -sign;
 			} else if (!comp(*other, *i))
 				return 0;
-			--i; --other;
+			--i; if (other != first) --other;
 		}
 		if (!swapped)
 			return sign;
@@ -232,7 +232,7 @@
 				flag = other;
 				swapped = true;
 			}
-			--i; --other;
+			--i; if (other != first) --other;
 		}
 		if (!swapped)
 			return;
