mirror of https://github.com/CGAL/cgal
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).
This commit is contained in:
parent
afd4cfbfef
commit
2c236ff01d
|
|
@ -52,19 +52,21 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
Filter_circulator(const Circ& c, const Pred& p=Pred())
|
Filter_circulator(const Circ& c, const Pred& p=Pred())
|
||||||
: Circ(c), is_null(false), test(p)
|
: test(p)
|
||||||
{
|
{
|
||||||
if(test(static_cast<Circ&>(*this)))
|
Circ circ(c);
|
||||||
|
if(test(circ))
|
||||||
is_null=false;
|
is_null=false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Self end(*this);
|
Circ end(c);
|
||||||
do {
|
do {
|
||||||
this->Circ::operator++();
|
++circ;
|
||||||
} while( !test(static_cast<Circ&>(*this)) && (*this)!=end );
|
} while( !test(circ) && end != circ );
|
||||||
if((*this)==end)
|
is_null = (end == circ);
|
||||||
is_null=true;
|
|
||||||
}
|
}
|
||||||
|
static_cast<Circ&>(*this) = circ;
|
||||||
|
CGAL_assertion(is_null || test(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==( Nullptr_t ) const {
|
bool operator==( Nullptr_t ) const {
|
||||||
|
|
@ -87,6 +89,7 @@ public:
|
||||||
do {
|
do {
|
||||||
this->Circ::operator++();
|
this->Circ::operator++();
|
||||||
} while( !test(static_cast<Circ&>(*this)) );
|
} while( !test(static_cast<Circ&>(*this)) );
|
||||||
|
CGAL_assertion(is_null || test(static_cast<Circ&>(*this)));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue