From 554722426543a6e1445ead11167107a69fd21af9 Mon Sep 17 00:00:00 2001 From: Alexei Sheplyakov Date: Sat, 8 Aug 2009 13:02:47 +0300 Subject: [PATCH] G_eval: fix incorrect use of STL iterator. According to [lib.bidirectional.iterators] it's not OK to decrement an iterator pointing to the beginning of the sequence. Fortunately random access iterators provided by (current versions of) gcc/libstdc++ don't have this silly limitation, so the code which works with pointers works with iterators without any changes at all. However, - there's no guarantee that the current behavior won't change in the future - some non-GNU compilers are not that smart (i.e. the program segfaults upon when decrementing beginning-of-the-sequence iterator). (cherry picked from commit dda45abd8a2c408f8b3eb7959a10dfb2468ecc3a) --- ginac/inifcns_nstdsums.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ginac/inifcns_nstdsums.cpp b/ginac/inifcns_nstdsums.cpp index 2c4061a9..b4105338 100644 --- a/ginac/inifcns_nstdsums.cpp +++ b/ginac/inifcns_nstdsums.cpp @@ -569,11 +569,12 @@ ex G_eval(const Gparameter& a, int scale, const exvector& gsyms) Gparameter newa; Gparameter::const_iterator it2 = short_a.begin(); - for (--it2; it2 != it;) { - ++it2; + for (; it2 != it; ++it2) { newa.push_back(*it2); } + newa.push_back(*it); newa.push_back(a[0]); + it2 = it; ++it2; for (; it2 != short_a.end(); ++it2) { newa.push_back(*it2); -- 2.44.0