Initialize numbers in operator>>(istream&, Point/Vector/..)

When we do not do that, and after the reading access a coordinate
some versions of g++ warn on -Wmaybe-uninitialized

The initialization costs nothing compared to the IO operation itself.
This commit is contained in:
Andreas Fabri 2016-10-13 09:14:17 +02:00
parent 119d5b345c
commit 5ca5877104
11 changed files with 12 additions and 10 deletions

View File

@ -39,6 +39,7 @@ template < typename K_base >
class Equal_2
: public K_base::Equal_2
{
typedef typename K_base::FT FT;
typedef typename K_base::Point_2 Point_2;
typedef typename K_base::Vector_2 Vector_2;
typedef typename K_base::Equal_2 Base;
@ -68,6 +69,7 @@ public:
Get_approx<Point_2> get_approx; // Identity functor for all points
// but lazy points
double px, py, qx, qy;
init_double(px, py,qx, qy, (FT*)(0));
if (fit_in_double(get_approx(p).x(), px) && fit_in_double(get_approx(p).y(), py) &&
fit_in_double(get_approx(q).x(), qx) && fit_in_double(get_approx(q).y(), qy) )

View File

@ -271,7 +271,7 @@ std::istream&
extract(std::istream& is, Circle_2<R>& c)
{
typename R::Point_2 center;
typename R::FT squared_radius;
typename R::FT squared_radius(0);
int o;
switch(get_mode(is)) {
case IO::ASCII :

View File

@ -231,7 +231,7 @@ template <class R >
std::istream&
extract(std::istream& is, Direction_2<R>& d, const Cartesian_tag&)
{
typename R::FT x, y;
typename R::FT x(0), y(0);
switch(get_mode(is)) {
case IO::ASCII :
is >> iformat(x) >> iformat(y);

View File

@ -188,7 +188,7 @@ template <class R >
std::istream&
extract(std::istream& is, Direction_3<R>& d, const Cartesian_tag&)
{
typename R::FT x, y, z;
typename R::FT x(0), y(0), z(0);
switch(get_mode(is)) {
case IO::ASCII :
is >> iformat(x) >> iformat(y) >> iformat(z);

View File

@ -260,7 +260,7 @@ template <class R >
std::istream&
extract(std::istream& is, Line_2<R>& l)
{
typename R::RT a, b, c;
typename R::RT a(0), b(0), c(0);
switch(get_mode(is)) {
case IO::ASCII :
is >> iformat(a) >> iformat(b) >> iformat(c);

View File

@ -257,7 +257,7 @@ template < class R >
std::istream &
operator>>(std::istream &is, Plane_3<R> &p)
{
typename R::RT a, b, c, d;
typename R::RT a(0), b(0), c(0), d(0);
switch(get_mode(is)) {
case IO::ASCII :
is >> iformat(a) >> iformat(b) >> iformat(c) >> iformat(d);

View File

@ -214,7 +214,7 @@ template <class R >
std::istream&
extract(std::istream& is, Point_2<R>& p, const Cartesian_tag&)
{
typename R::FT x, y;
typename R::FT x(0), y(0);
switch(get_mode(is)) {
case IO::ASCII :
is >> iformat(x) >> iformat(y);

View File

@ -242,7 +242,7 @@ template <class R >
std::istream&
extract(std::istream& is, Point_3<R>& p, const Cartesian_tag&)
{
typename R::FT x, y, z;
typename R::FT x(0), y(0), z(0);
switch(get_mode(is)) {
case IO::ASCII :
is >> iformat(x) >> iformat(y) >> iformat(z);

View File

@ -289,7 +289,7 @@ std::istream&
extract(std::istream& is, Sphere_3<R>& c, const Cartesian_tag&)
{
typename R::Point_3 center;
typename R::FT squared_radius;
typename R::FT squared_radius(0);
int o=0;
switch(get_mode(is)) {
case IO::ASCII :

View File

@ -299,7 +299,7 @@ template <class R >
std::istream&
extract(std::istream& is, Vector_2<R>& v, const Cartesian_tag&)
{
typename R::FT x, y;
typename R::FT x(0), y(0);
switch(get_mode(is)) {
case IO::ASCII :
is >> iformat(x) >> iformat(y);

View File

@ -279,7 +279,7 @@ template <class R >
std::istream&
extract(std::istream& is, Vector_3<R>& v, const Cartesian_tag&)
{
typename R::FT x, y, z;
typename R::FT x(0), y(0), z(0);
switch(get_mode(is)) {
case IO::ASCII :
is >> iformat(x) >> iformat(y) >> iformat(z);