From 896d5a7bd9aed6558d29338f58c4b3aab7eaecc3 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 11 Feb 2019 14:50:50 +0100 Subject: [PATCH] Quiet a warning [-Wmaybe-uninitialized] ``` [ 50%] Building CXX object CMakeFiles/test_exact_offset.dir/test_exact_offset.cpp.o /usr/local/bin/c++ -DCGAL_TEST_SUITE=1 -DCGAL_USE_CORE=1 -DCGAL_USE_GMP -DCGAL_USE_MPFR -isystem /usr/include/x86_64-linux-gnu -I/home/cgal_tester/build/src/cmake/platforms/Ubuntu-latest-GCC6-Release/test/Minkowski_sum_2 -I/home/cgal_tester/build/src/cmake/platforms/Ubuntu-latest-GCC6-Release/include -I/mnt/testsuite/include -DDONT_USE_BOOST_PROGRAM_OPTIONS -Wall -Wextra -O3 -DCGAL_NDEBUG -frounding-math -Wall -frounding-math -o CMakeFiles/test_exact_offset.dir/test_exact_offset.cpp.o -c /home/cgal_tester/build/src/cmake/platforms/Ubuntu-latest-GCC6-Release/test/Minkowski_sum_2/test_exact_offset.cpp In file included from /mnt/testsuite/include/CGAL/Cartesian/Weighted_point_2.h:29, from /mnt/testsuite/include/CGAL/Cartesian/Cartesian_base.h:34, from /mnt/testsuite/include/CGAL/Cartesian.h:29, from /home/cgal_tester/build/src/cmake/platforms/Ubuntu-latest-GCC6-Release/test/Minkowski_sum_2/test_exact_offset.cpp:16: /mnt/testsuite/include/CGAL/Handle_for.h: In function 'OutputIterator CGAL::partition_approx_convex_2(InputIterator, InputIterator, OutputIterator, const Traits&) [with InputIterator = __gnu_cxx::__normal_iterator >*, std::vector >, std::allocator > > > >; Traits = CGAL::Partition_traits_2; OutputIterator = std::back_insert_iterator >, std::allocator > > > >, std::allocator >, std::allocator > > > > > > >]': /mnt/testsuite/include/CGAL/Handle_for.h:313:12: warning: '*((void*)& target +40)' may be used uninitialized in this function [-Wmaybe-uninitialized] 313 | return *(h.Ptr()); In file included from /mnt/testsuite/include/CGAL/partition_2.h:30, from /mnt/testsuite/include/CGAL/Minkowski_sum_2/Decomposition_strategy_adapter.h:31, from /mnt/testsuite/include/CGAL/Polygon_convex_decomposition_2.h:27, from /home/cgal_tester/build/src/cmake/platforms/Ubuntu-latest-GCC6-Release/test/Minkowski_sum_2/test_exact_offset.cpp:22: /mnt/testsuite/include/CGAL/Partition_2/partition_approx_convex_2.h:173:23: note: '*((void*)& target +40)' was declared here 173 | Circulator source, target, before_s, after_s; | ^~~~~~ ``` It seems sufficient to declare the variables at a smaller scope. Strange... --- .../include/CGAL/Partition_2/partition_approx_convex_2.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Partition_2/include/CGAL/Partition_2/partition_approx_convex_2.h b/Partition_2/include/CGAL/Partition_2/partition_approx_convex_2.h index 6f1ebe295b1..d80406831e4 100644 --- a/Partition_2/include/CGAL/Partition_2/partition_approx_convex_2.h +++ b/Partition_2/include/CGAL/Partition_2/partition_approx_convex_2.h @@ -170,7 +170,6 @@ OutputIterator partition_approx_convex_2(InputIterator first, } while (++c != first_c); Segment_2 edge; - Circulator source, target, before_s, after_s; #ifdef CGAL_PARTITION_APPROX_CONVEX_DEBUG std::cout << "Inserting diagonals: " << std::endl; @@ -207,10 +206,10 @@ OutputIterator partition_approx_convex_2(InputIterator first, if (!triangles.is_infinite(*e_circ)) { edge = triangles.segment((*e_circ).first, (*e_circ).second); - source = edge.source(); - target = edge.target(); - before_s = source; before_s--; - after_s = source; after_s++; + Circulator source = edge.source(); + Circulator target = edge.target(); + Circulator before_s = source; before_s--; + Circulator after_s = source; after_s++; #ifdef CGAL_PARTITION_APPROX_CONVEX_DEBUG std::cout << "considering " << *source << " " << *target << "...";