From: David Wells Date: Fri, 28 Aug 2020 13:27:51 +0000 (-0400) Subject: Fix two minor warnings in BoundingBox. X-Git-Tag: v9.3.0-rc1~1161^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4cb57d24178b23c41bab5dab9829ac180540513e;p=dealii.git Fix two minor warnings in BoundingBox. GCC 10.2.0 has two new warnings: 1. Whenever dim is unsigned, equal to 0, and we check dim < 0 we get a type limits warning. 2. When spacedim = 2 we get a warning that both OR statements are equivalent. Make GCC happy by subtracting instead (and make things clearer by switching to a signed dimension). --- diff --git a/include/deal.II/base/bounding_box.h b/include/deal.II/base/bounding_box.h index 36d515d40e..c842c8796a 100644 --- a/include/deal.II/base/bounding_box.h +++ b/include/deal.II/base/bounding_box.h @@ -362,19 +362,19 @@ namespace internal * dimension to a coordinate index in dim + 1 dimensions. * * @param locked_coordinate should be in the range [0, dim+1). - * @param coordiante_in_dim should be in the range [0, dim). + * @param coordinate_in_dim should be in the range [0, dim). * @return A coordinate index in the range [0, dim+1) * * @relates BoundingBox */ template - inline unsigned int - coordinate_to_one_dim_higher(const unsigned int locked_coordinate, - const unsigned int coordiante_in_dim) + inline int + coordinate_to_one_dim_higher(const int locked_coordinate, + const int coordinate_in_dim) { AssertIndexRange(locked_coordinate, dim + 1); - AssertIndexRange(coordiante_in_dim, dim); - return (locked_coordinate + coordiante_in_dim + 1) % (dim + 1); + AssertIndexRange(coordinate_in_dim, dim); + return (locked_coordinate + coordinate_in_dim + 1) % (dim + 1); } } // namespace internal diff --git a/source/base/bounding_box.cc b/source/base/bounding_box.cc index 73ff6d088a..f4d9ec10e3 100644 --- a/source/base/bounding_box.cc +++ b/source/base/bounding_box.cc @@ -96,8 +96,7 @@ BoundingBox::get_neighbor_type( } // Finding the intersection's dimension - - unsigned int intersect_dim = spacedim; + int intersect_dim = spacedim; for (unsigned int d = 0; d < spacedim; ++d) if (std::abs(intersect_bbox_min[d] - intersect_bbox_max[d]) <= std::numeric_limits::epsilon() * @@ -105,7 +104,7 @@ BoundingBox::get_neighbor_type( std::abs(intersect_bbox_max[d]))) --intersect_dim; - if (intersect_dim == 0 || intersect_dim + 2 == spacedim) + if (intersect_dim == 0 || intersect_dim == spacedim - 2) return NeighborType::simple_neighbors; // Checking the two mergeable cases: first if the boxes are aligned so