Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adress g++ -Wmaybe-uninitialized warnings #695

Merged
merged 2 commits into from
Feb 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,9 @@ _merge_two_intervals(Edge_const_handle e1, bool is_leftmost1,
// This is the rightmost vertex in the current minimization diagram (out_d).
// The intersection points/curves that interest us are the ones in
// [v_leftmost, v].
// Without using make_optional we get a "maybe uninitialized" warning with gcc -Wall
boost::optional<Vertex_const_handle> v_leftmost =
boost::optional<Vertex_const_handle>();
boost::make_optional(false, Vertex_const_handle());

if (is_leftmost1 == true) {
if (is_leftmost2 == false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace CGAL { namespace internal { namespace Static_filters_predicates {
// but Lazy ones.

double px, py, pz, qx, qy, qz, rx, ry, rz, sx, sy, sz, alpha;
init_double(px, py, pz, qx, qy, qz, rx, ry, rz, sx, sy, sz, alpha, (FT*)(0));

if( fit_in_double(get_approx(p).x(), px) && fit_in_double(get_approx(p).y(), py) &&
fit_in_double(get_approx(p).z(), pz) &&
Expand Down Expand Up @@ -216,6 +217,8 @@ namespace CGAL { namespace internal { namespace Static_filters_predicates {
CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Compare_squared_radius_3 with 3 points", tmp);

double px, py, pz, qx, qy, qz, sx, sy, sz, alpha;
init_double(px, py, pz, qx, qy, qz, sx, sy, sz, alpha, (FT*)(0));

if( fit_in_double(p.x(), px) && fit_in_double(p.y(), py) &&
fit_in_double(p.z(), pz) &&
fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) &&
Expand Down Expand Up @@ -347,6 +350,7 @@ namespace CGAL { namespace internal { namespace Static_filters_predicates {
CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Compare_squared_radius_3 with 2 points", tmp);

double px, py, pz, qx, qy, qz, alpha;
init_double(px, py, pz, qx, qy, qz, alpha, (FT*)(0));
if( fit_in_double(p.x(), px) && fit_in_double(p.y(), py) &&
fit_in_double(p.z(), pz) &&
fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) &&
Expand Down
97 changes: 97 additions & 0 deletions Filtered_kernel/include/CGAL/internal/Static_filters/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,103 @@ inline bool diff_was_exact(double a, double b, double ab)
return ab+b == a && a-ab == b;
}

template < typename T >
inline void init_double(double&, T* ) {}

template < typename T >
inline void init_double(double&, double&, T* ) {}

template < typename T >
inline void init_double(double&, double&, double&, T* ) {}

template < typename T >
inline void init_double(double&, double&, double&, double&, T* ) {}

template < typename T >
inline void init_double(double&, double&, double&, double&, double&, T* ) {}

template < typename T >
inline void init_double(double&, double&, double&, double&, double&, double&, T* ) {}

template < typename T >
inline void init_double(double&, double&, double&, double&, double&, double&, double&, T* ) {}

template < typename T >
inline void init_double(double&, double&, double&, double&, double&, double&, double&, double&, T* ) {}

template < typename T >
inline void init_double(double&, double&, double&,double&, double&, double&, double&, double&, double&, T* ) {}

template < typename T >
inline void init_double(double&, double&, double&, double&, double&, double&, double&, double&, double&, double&, T* ) {}


template < typename T >
inline void init_double(double&, double&, double&, double&, double&, double&, double&, double&, double&, double&, double&, T* ) {}


template < typename T >
inline void init_double(double&, double&, double&, double&, double&, double&, double&, double&, double&, double&, double&, double&, T* ) {}


template < typename T >
inline void init_double(double&, double&, double&, double&, double&, double&, double&, double&, double&, double&, double&, double&, double&, T* ) {}



template < typename ET >
inline void init_double(double& d0, Lazy_exact_nt<ET>* )
{d0 = 0;}

template < typename ET >
inline void init_double(double& d0, double& d1, Lazy_exact_nt<ET>* )
{d0 = d1 = 0;}

template < typename ET >
inline void init_double(double& d0, double& d1, double& d2, Lazy_exact_nt<ET>* )
{d0 = d1 = d2 = 0;}

template < typename ET >
inline void init_double(double& d0, double& d1, double& d2, double& d3, Lazy_exact_nt<ET>* )
{d0 = d1 = d2 = d3 = 0;}

template < typename ET >
inline void init_double(double& d0, double& d1, double& d2, double& d3, double& d4, Lazy_exact_nt<ET>* )
{d0 = d1 = d2 = d3 = d4 = 0;}

template < typename ET >
inline void init_double(double& d0, double& d1, double& d2, double& d3, double& d4, double& d5, Lazy_exact_nt<ET>* )
{d0 = d1 = d2 = d3 = d4 = d5 = 0;}

template < typename ET >
inline void init_double(double& d0, double& d1, double& d2, double& d3, double& d4, double& d5, double& d6, Lazy_exact_nt<ET>* )
{d0 = d1 = d2 = d3 = d4 = d5 = d6 = 0;}

template < typename ET >
inline void init_double(double& d0, double& d1, double& d2, double& d3, double& d4, double& d5, double& d6, double& d7, Lazy_exact_nt<ET>* )
{d0 = d1 = d2 = d3 = d4 = d5 = d6 = d7 = 0;}

template < typename ET >
inline void init_double(double& d0, double& d1, double& d2, double& d3, double& d4, double& d5, double& d6, double& d7, double& d8, Lazy_exact_nt<ET>* )
{d0 = d1 = d2 = d3 = d4 = d5 = d6 = d7 = d8 = 0;}

template < typename ET >
inline void init_double(double& d0, double& d1, double& d2, double& d3, double& d4, double& d5, double& d6, double& d7, double&d8, double& d9, Lazy_exact_nt<ET>* )
{d0 = d1 = d2 = d3 = d4 = d5 = d6 = d7 = d8 = d9 = 0;}

template < typename ET >
inline void init_double(double& d0, double& d1, double& d2, double& d3, double& d4, double& d5, double& d6, double& d7, double&d8, double& d9, double& d10, Lazy_exact_nt<ET>* )
{d0 = d1 = d2 = d3 = d4 = d5 = d6 = d7 = d8 = d9 = d10 = 0;}

template < typename ET >
inline void init_double(double& d0, double& d1, double& d2, double& d3, double& d4, double& d5, double& d6, double& d7, double&d8, double& d9, double& d10, double& d11, Lazy_exact_nt<ET>* )
{d0 = d1 = d2 = d3 = d4 = d5 = d6 = d7 = d8 = d9 = d10 = d11 = 0;}

template < typename ET >
inline void init_double(double& d0, double& d1, double& d2, double& d3, double& d4, double& d5, double& d6, double& d7, double&d8, double& d9, double& d10, double& d11, double& d12, Lazy_exact_nt<ET>* )
{d0 = d1 = d2 = d3 = d4 = d5 = d6 = d7 = d8 = d9 = d10 = d11 = d12 = 0;}


// Auxiliary function to check if static filters can be applied, that is,
// if to_double() does not add roundoff errors.
// TODO :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
#ifndef CGAL_PARTITION_APPROX_CONVEX_H
#define CGAL_PARTITION_APPROX_CONVEX_H

#include <boost/config.hpp>
#if (BOOST_GCC >= 40800)
_Pragma("GCC diagnostic push")
_Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
#endif

#include <CGAL/Constrained_triangulation_2.h>
#include <CGAL/Partition_2/Triangulation_indirect_traits_2.h>
#include <CGAL/Partition_2/Turn_reverser.h>
Expand Down Expand Up @@ -271,5 +277,7 @@ OutputIterator partition_approx_convex_2(InputIterator first,
}

}

#if (BOOST_GCC >= 40800)
_Pragma("GCC diagnostic pop")
#endif
#endif // CGAL_PARTITION_APPROX_CONVEX_H
2 changes: 1 addition & 1 deletion Surface_mesher/test/Surface_mesher/test_c2t3_iterators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main(int , char**)
for(int i = 0; i < 2; ++i)
{
Tr::Cell_handle cell;
int i1, i2, i3;
int i1=0, i2=0, i3=0; // initialize to avoid a g++ -Wall warning
tr.is_facet(v[i+1], v[(i+2)&3], v[(i+3)&3],
cell,
i1, i2, i3);
Expand Down