From 88f9f009226546f61618fae9bc4ab2f97ec1d217 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 25 Sep 2025 16:25:37 +0200 Subject: [PATCH] fix warning -Wstringop-overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix that warning, due to a copy of `tuple` in compare operators for `std::sort` and `std::unique`, in `CGAL::Polygon_mesh_processing::autorefine_impl::collect_intersections`. ``` In member function ‘std::__atomic_base<_IntTp>::__int_type std::__atomic_base<_IntTp>::fetch_add(__int_type, std::memory_order) [with _ITp = int]’, inlined from ‘void CGAL::Handle::incref() const’ at /mnt/testsuite/include/CGAL/Handle.h:87:29, inlined from ‘CGAL::Handle::Handle(const CGAL::Handle&)’ at /mnt/testsuite/include/CGAL/Handle.h:55:13, inlined from ‘CGAL::Lazy > >, CGAL::Point_3 > >, CGAL::Cartesian_converter >, CGAL::Simple_cartesian >, CGAL::NT_converter<__gmp_expr<__mpq_struct [1], __mpq_struct [1]>, CGAL::Interval_nt > > >::Lazy(const CGAL::Lazy > >, CGAL::Point_3 > >, CGAL::Cartesian_converter >, CGAL::Simple_cartesian >, CGAL::NT_converter<__gmp_expr<__mpq_struct [1], __mpq_struct [1]>, CGAL::Interval_nt > > >&)’ at /mnt/testsuite/include/CGAL/Lazy.h:877:7, inlined from ‘CGAL::Point_3::Point_3(const CGAL::Point_3&)’ at /mnt/testsuite/include/CGAL/Point_3.h:30:7, inlined from ‘std::_Head_base<_Idx, _Head, false>::_Head_base(const std::_Head_base<_Idx, _Head, false>&) [with long unsigned int _Idx = 0; _Head = CGAL::Point_3]’ at /usr/include/c++/15/tuple:208:17, inlined from ‘std::_Tuple_impl<_Idx, _Head, _Tail ...>::_Tuple_impl(const std::_Tuple_impl<_Idx, _Head, _Tail ...>&) [with long unsigned int _Idx = 0; _Head = CGAL::Point_3; _Tail = {int, int}]’ at /usr/include/c++/15/tuple:318:17, inlined from ‘std::tuple< >::tuple(const std::tuple< >&) [with _Elements = {CGAL::Point_3, int, int}]’ at /usr/include/c++/15/tuple:1502:17, inlined from ‘bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = std::tuple, int, int>; _Iterator = __gnu_cxx::__normal_iterator, int, int>*, std::vector, int, int> > >; _Compare = CGAL::Polygon_mesh_processing::autorefine_impl::collect_intersections(const std::array, 3>&, const std::array, 3>&, std::vector, int, int> >&)::]’ at /usr/include/c++/15/bits/predefined_ops.h:240:23, inlined from ‘void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator, int, int>*, vector, int, int> > >; _Compare = __gnu_cxx::__ops::_Val_comp_iter(const std::array, 3>&, const std::array, 3>&, std::vector, int, int> >&):: >]’ at /usr/include/c++/15/bits/stl_algo.h:1758:20: /usr/include/c++/15/bits/atomic_base.h:631:34: warning: ‘unsigned int __atomic_fetch_add_4(volatile void*, unsigned int, int)’ writing 4 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=] 631 | { return __atomic_fetch_add(&_M_i, __i, int(__m)); } | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ ``` See for example https://cgal.geometryfactory.com/CGAL/testsuite/CGAL-6.2-Ic-6/Constrained_triangulation_3_Examples/TestReport_cgaltest_Fedora-rawhide-Release.gz --- .../include/CGAL/Polygon_mesh_processing/autorefinement.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/autorefinement.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/autorefinement.h index 54fce583918..9432e29a421 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/autorefinement.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/autorefinement.h @@ -475,8 +475,8 @@ bool collect_intersections(const std::array& t1, // #warning TODO get rid of sort and unique calls // because we don't handle intersection type and can have edge-edge edge-vertex duplicates - std::sort(inter_pts.begin(), inter_pts.end(), [](auto p, auto q){return std::get<0>(p)(q);}); - auto last = std::unique(inter_pts.begin(), inter_pts.end(), [](auto p, auto q){return std::get<0>(p)==std::get<0>(q);}); + std::sort(inter_pts.begin(), inter_pts.end(), [](const auto& p, const auto& q){return std::get<0>(p)(q);}); + auto last = std::unique(inter_pts.begin(), inter_pts.end(), [](const auto& p, const auto& q){return std::get<0>(p)==std::get<0>(q);}); inter_pts.erase(last, inter_pts.end()); #ifdef CGAL_AUTOREF_DEBUG_DEPTH