From 2c236ff01da8c0a0958b9eb4dee9216bc5236a89 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 9 Jan 2014 14:15:45 +0100 Subject: [PATCH] Fix a bug in the constructor if Filter_circulator The Intel Compiler 14.0, with -O2 or -O3, triggers a bug in the old version of the code. After the construction of the filtered circulator, `test(*this)` was not guaranteed. I am not sure if the bug is in the code or in the compiler, but the constructor was an ugly piece of code! (*this) was used in the body of the constructor in non obvious ways. An object is reputed constructed once the internalizers are evaluated, as far as I know, so probably the previous version of the code was valid. However, that sound strange to copy an object inside the body of the constructor of that object. Maybe that confused the compiler. Anyway, I have modified the implementation of that constructor in a cleaner way, and I have added an assertion (that was failing with the old implementation). --- Mesh_2/include/CGAL/Filter_circulator.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Mesh_2/include/CGAL/Filter_circulator.h b/Mesh_2/include/CGAL/Filter_circulator.h index bf53f0d6db7..2de6496bc1d 100644 --- a/Mesh_2/include/CGAL/Filter_circulator.h +++ b/Mesh_2/include/CGAL/Filter_circulator.h @@ -52,19 +52,21 @@ public: } Filter_circulator(const Circ& c, const Pred& p=Pred()) - : Circ(c), is_null(false), test(p) + : test(p) { - if(test(static_cast(*this))) + Circ circ(c); + if(test(circ)) is_null=false; else { - Self end(*this); + Circ end(c); do { - this->Circ::operator++(); - } while( !test(static_cast(*this)) && (*this)!=end ); - if((*this)==end) - is_null=true; + ++circ; + } while( !test(circ) && end != circ ); + is_null = (end == circ); } + static_cast(*this) = circ; + CGAL_assertion(is_null || test(*this)); } bool operator==( Nullptr_t ) const { @@ -87,6 +89,7 @@ public: do { this->Circ::operator++(); } while( !test(static_cast(*this)) ); + CGAL_assertion(is_null || test(static_cast(*this))); return *this; }