Fix a warning [-Wmaybe-uninitialized] in Algebraic_kernel_d

```
[ 50%] Building CXX object CMakeFiles/Algebraic_kernel_d_2.dir/Algebraic_kernel_d_2.cpp.o
/usr/local/bin/c++  -DCGAL_TEST_SUITE=1 -DCGAL_USE_CORE=1 -DCGAL_USE_GMP -DCGAL_USE_GMPXX -DCGAL_USE_MPFI -DCGAL_USE_MPFR -I/home/cgal_tester/build/src/cmake/platforms/Ubuntu-latest-GCC6-Release/test/Algebraic_kernel_d/include -isystem /usr/include/x86_64-linux-gnu -I/home/cgal_tester/build/src/cmake/platforms/Ubuntu-latest-GCC6-Release/test/Algebraic_kernel_d -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/Algebraic_kernel_d_2.dir/Algebraic_kernel_d_2.cpp.o -c /home/cgal_tester/build/src/cmake/platforms/Ubuntu-latest-GCC6-Release/test/Algebraic_kernel_d/Algebraic_kernel_d_2.cpp
In file included from /mnt/testsuite/include/CGAL/Polynomial.h:44,
                 from /mnt/testsuite/include/CGAL/Algebraic_kernel_d_1.h:37,
                 from /mnt/testsuite/include/CGAL/Algebraic_kernel_d_2.h:31,
                 from /home/cgal_tester/build/src/cmake/platforms/Ubuntu-latest-GCC6-Release/test/Algebraic_kernel_d/Algebraic_kernel_d_2.cpp:25:
/mnt/testsuite/include/CGAL/Handle_with_policy.h: In member function 'void CGAL::Curve_pair_analysis_2<AlgebraicKernelWithAnalysis_2>::compute_event_x_coordinates_with_event_indices() const [with AlgebraicKernelWithAnalysis_2 = CGAL::Algebraic_curve_kernel_2<CGAL::Algebraic_kernel_d_1<CORE::BigInt, CORE::BigRat, CGAL::internal::Algebraic_real_rep<CORE::BigInt, CORE::BigRat>, CGAL::internal::Descartes<CGAL::Polynomial<CORE::BigInt>, CORE::BigRat> > >]':
/mnt/testsuite/include/CGAL/Handle_with_policy.h:1014:28: warning: '*((void*)&<anonymous> +8)' may be used uninitialized in this function [-Wmaybe-uninitialized]
 1014 |         Handle_policy::find( h);
      |         ~~~~~~~~~~~~~~~~~~~^~~~
/mnt/testsuite/include/CGAL/Handle_with_policy.h:1014:28: warning: '*((void*)&<anonymous> +8)' may be used uninitialized in this function [-Wmaybe-uninitialized]
 1014 |         Handle_policy::find( h);
      |         ~~~~~~~~~~~~~~~~~~~^~~~
/mnt/testsuite/include/CGAL/Handle_with_policy.h:1014:28: warning: '*((void*)&<anonymous> +8)' may be used uninitialized in this function [-Wmaybe-uninitialized]
 1014 |         Handle_policy::find( h);
      |         ~~~~~~~~~~~~~~~~~~~^~~~
```

The warning is because an uninitialized `optional` is copied (in a
`push_back()`). The fix is to use `emplace_back()` to construct it
directly in the vector, instead of copying it.
This commit is contained in:
Laurent Rineau 2019-02-08 10:33:04 +01:00
parent b84f54a9e3
commit 3ba6262fb5
1 changed files with 15 additions and 2 deletions

View File

@ -1435,7 +1435,13 @@ compute_event_x_coordinates_with_event_indices() const {
CGAL_ACK_DEBUG_PRINT << " one curve event" << std::endl; CGAL_ACK_DEBUG_PRINT << " one curve event" << std::endl;
#endif #endif
*/ */
#if CGAL_CXX11
// Fix a warning by using `emplace_back()` instead of
// copying a non-initialized `optional
this->ptr()->event_slices.emplace_back();
#else
this->ptr()->event_slices.push_back(Lazy_status_line_CPA_1()); this->ptr()->event_slices.push_back(Lazy_status_line_CPA_1());
#endif
switch(*(one_curve_it++)) { switch(*(one_curve_it++)) {
case(CGAL::internal::ROOT_OF_FIRST_SET): { case(CGAL::internal::ROOT_OF_FIRST_SET): {
event_indices.push_back(Event_indices(-1,f_count,-1)); event_indices.push_back(Event_indices(-1,f_count,-1));
@ -1462,8 +1468,11 @@ compute_event_x_coordinates_with_event_indices() const {
CGAL_ACK_DEBUG_PRINT << " two curve event" << std::endl; CGAL_ACK_DEBUG_PRINT << " two curve event" << std::endl;
#endif #endif
*/ */
this->ptr()-> #if CGAL_CXX11
event_slices.push_back(Lazy_status_line_CPA_1()); this->ptr()->event_slices.emplace_back();
#else
this->ptr()->event_slices.push_back(Lazy_status_line_CPA_1());
#endif
event_indices.push_back event_indices.push_back
(Event_indices(inter_count,-1,-1)); (Event_indices(inter_count,-1,-1));
@ -1477,7 +1486,11 @@ compute_event_x_coordinates_with_event_indices() const {
<< std::endl; << std::endl;
#endif #endif
*/ */
#if CGAL_CXX11
this->ptr()->event_slices.emplace_back();
#else
this->ptr()->event_slices.push_back(Lazy_status_line_CPA_1()); this->ptr()->event_slices.push_back(Lazy_status_line_CPA_1());
#endif
switch(*(one_curve_it++)) { switch(*(one_curve_it++)) {