[geos-devel] [GEOS] #638: Recommend a static_cast around assert strings

GEOS geos-trac at osgeo.org
Tue Jan 31 10:54:37 PST 2017


#638: Recommend a static_cast around assert strings
------------------------+---------------------------
 Reporter:  goatbar     |       Owner:  geos-devel@…
     Type:  defect      |      Status:  new
 Priority:  major       |   Milestone:  3.7.0
Component:  Default     |     Version:  3.3.8
 Severity:  Unassigned  |  Resolution:
 Keywords:              |
------------------------+---------------------------

Comment (by goatbar):

 Ping.  I just had to remerge 3.6.1 downstream.  Here is my patch:

 {{{#!diff
 diff --git a/geos/geos-3.6.1/src/geom/util/GeometryEditor.cpp
 b/geos/geos-3.6.1/src/geom/util/GeometryEditor.cpp
 index c70fa1e..0f9b589 100644
 --- a/geos/geos-3.6.1/src/geom/util/GeometryEditor.cpp
 +++ b/geos/geos-3.6.1/src/geom/util/GeometryEditor.cpp
 @@ -99,7 +99,7 @@ GeometryEditor::edit(const Geometry *geometry,
 GeometryEditorOperation *operatio
    }

      // Unsupported Geometry classes should be caught in the
 GeometryEditorOperation.
 -    assert(!"SHOULD NEVER GET HERE");
 +    assert(!static_cast<bool>("SHOULD NEVER GET HERE"));
      return NULL;
  }

 diff --git a/geos/geos-3.6.1/src/index/strtree/AbstractSTRtree.cpp
 b/geos/geos-3.6.1/src/index/strtree/AbstractSTRtree.cpp
 index f11401a..84e7a86 100644
 --- a/geos/geos-3.6.1/src/index/strtree/AbstractSTRtree.cpp
 +++ b/geos/geos-3.6.1/src/index/strtree/AbstractSTRtree.cpp
 @@ -370,7 +370,7 @@ ItemsList* AbstractSTRtree::itemsTree(AbstractNode*
 node)
                  static_cast<ItemBoundable*>(childBoundable)->getItem());
          }
          else {
 -            assert(!"should never be reached");
 +            assert(!static_cast<bool>("should never be reached"));
          }
      }
      if (valuesTreeForNode->empty())
 @@ -395,4 +395,3 @@ ItemsList* AbstractSTRtree::itemsTree()
  } // namespace geos.index.strtree
  } // namespace geos.index
  } // namespace geos
 -
 diff --git a/geos/geos-3.6.1/src/linearref/ExtractLineByLocation.cpp
 b/geos/geos-3.6.1/src/linearref/ExtractLineByLocation.cpp
 index 04b3690..4928da5 100644
 --- a/geos/geos-3.6.1/src/linearref/ExtractLineByLocation.cpp
 +++ b/geos/geos-3.6.1/src/linearref/ExtractLineByLocation.cpp
 @@ -79,7 +79,7 @@ Geometry *ExtractLineByLocation::reverse(const Geometry
 *linear)
                 }
                 else
                 {
 -                       assert(!"non-linear geometry encountered");
 +                       assert(!!static_cast<bool>("non-linear geometry
 encountered"));
              return 0;
                 }
         }
 diff --git a/geos/geos-3.6.1/src/operation/union/CascadedPolygonUnion.cpp
 b/geos/geos-3.6.1/src/operation/union/CascadedPolygonUnion.cpp
 index 92ec6da..64e66c7 100644
 --- a/geos/geos-3.6.1/src/operation/union/CascadedPolygonUnion.cpp
 +++ b/geos/geos-3.6.1/src/operation/union/CascadedPolygonUnion.cpp
 @@ -139,7 +139,7 @@
 CascadedPolygonUnion::reduceToGeometries(index::strtree::ItemsList*
 geomTree)
 geoms->push_back(reinterpret_cast<geom::Geometry*>((*i).get_geometry()));
          }
          else {
 -            assert(!"should never be reached");
 +            assert(!static_cast<bool>("should never be reached"));
          }
      }

 @@ -247,4 +247,3 @@
 CascadedPolygonUnion::restrictToPolygons(std::auto_ptr<geom::Geometry> g)
  } // namespace geos.operation.union
  } // namespace geos.operation
  } // namespace geos
 -
 diff --git a/geos/geos-3.6.1/src/operation/union/CascadedUnion.cpp
 b/geos/geos-3.6.1/src/operation/union/CascadedUnion.cpp
 index 4bd522a..744dae6 100644
 --- a/geos/geos-3.6.1/src/operation/union/CascadedUnion.cpp
 +++ b/geos/geos-3.6.1/src/operation/union/CascadedUnion.cpp
 @@ -116,7 +116,7 @@
 CascadedUnion::reduceToGeometries(index::strtree::ItemsList* geomTree)
 geoms->push_back(reinterpret_cast<geom::Geometry*>((*i).get_geometry()));
          }
          else {
 -            assert(!"should never be reached");
 +            assert(!static_cast<bool>("should never be reached"));
          }
      }

 @@ -195,4 +195,3 @@ CascadedUnion::unionActual(geom::Geometry* g0,
 geom::Geometry* g1)
  } // namespace geos.operation.union
  } // namespace geos.operation
  } // namespace geos
 -
 }}}

--
Ticket URL: <https://trac.osgeo.org/geos/ticket/638#comment:7>
GEOS <http://trac.osgeo.org/geos>
GEOS (Geometry Engine - Open Source) is a C++ port of the Java Topology Suite (JTS).


More information about the geos-devel mailing list