From b669bb2d1376ed0cbbe54bb6a1c5d3d6ddc428fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 28 Apr 2017 14:38:27 +0200 Subject: [PATCH] Copy boost::bind return object The lazy kernel returns temporaries and gives garbage to compare_xyz_3... --- .../include/CGAL/Regular_triangulation_3.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Triangulation_3/include/CGAL/Regular_triangulation_3.h index 1d398065147..c5925efea48 100644 --- a/Triangulation_3/include/CGAL/Regular_triangulation_3.h +++ b/Triangulation_3/include/CGAL/Regular_triangulation_3.h @@ -1700,14 +1700,14 @@ dual(Cell_handle c) const // We sort the points lexicographically. const Weighted_point * points[5] = {&p0, &p1, &p2, &p3, &p}; - // It is important to tell boost::bind that we want references in return - // by writing `boost::bind(...)` otherwise we get temporaries - // and we call Compare_xyz_3 on objects that might have been cleaned + + // Lazy_Kernel::Construct_point_3 can return temporaries and so we have to + // copy the Bare_point... std::sort(points, points + 5, boost::bind(geom_traits().compare_xyz_3_object(), - boost::bind( + boost::bind( cp, boost::bind(Dereference(), _1)), - boost::bind( + boost::bind( cp, boost::bind(Dereference(), _2))) == SMALLER); @@ -1819,14 +1819,13 @@ dual(Cell_handle c) const // We sort the points lexicographically. const Weighted_point * points[4] = {&p0, &p1, &p2, &p}; - // It is important to tell boost::bind that we want references in return - // by writing `boost::bind(...)` otherwise we get temporaries - // and we call Compare_xyz_3 on objects that might have been cleaned + // Lazy_Kernel::Construct_point_3 can return temporaries and so we have to + // copy the Bare_point... std::sort(points, points + 4, boost::bind(geom_traits().compare_xyz_3_object(), - boost::bind( + boost::bind( cp, boost::bind(Dereference(), _1)), - boost::bind( + boost::bind( cp, boost::bind(Dereference(), _2))) == SMALLER);