Boost logo

Geometry :

Subject: [geometry] GCC 4.4.7 and strict aliasing warnings
From: Patrick J. LoPresti (lopresti_at_[hidden])
Date: 2014-10-27 19:32:00


(Using the develop branch)

This is with Red Hat Enterprise 6.5, although I suspect it will happen
with most RHEL 6 variants since they all use some variant of GCC
4.4.7. See the (short) program appended to this message.

Although I do not see how this even possible, since I do not see any
pointer or reference casts at all... GCC bug, maybe?

$ /usr/bin/g++ -I/path/to/modular-boost -O3 -Wall -S alias.cc
In file included from
/path/to/modular-boost/boost/geometry/index/detail/rtree/rstar/rstar.hpp:16,
                 from /path/to/modular-boost/boost/geometry/index/rtree.hpp:72,
                 from
/path/to/modular-boost/boost/geometry/algorithms/detail/closest_feature/range_to_range.hpp:23,
                 from
/path/to/modular-boost/boost/geometry/algorithms/detail/distance/range_to_geometry_rtree.hpp:26,
                 from
/path/to/modular-boost/boost/geometry/algorithms/detail/distance/multipoint_to_geometry.hpp:26,
                 from
/path/to/modular-boost/boost/geometry/algorithms/detail/distance/implementation.hpp:25,
                 from
/path/to/modular-boost/boost/geometry/algorithms/detail/comparable_distance/implementation.hpp:22,
                 from
/path/to/modular-boost/boost/geometry/algorithms/comparable_distance.hpp:23,
                 from
/path/to/modular-boost/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp:24,
                 from
/path/to/modular-boost/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp:32,
                 from
/path/to/modular-boost/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp:27,
                 from
/path/to/modular-boost/boost/geometry/algorithms/buffer.hpp:32,
                 from /path/to/modular-boost/boost/geometry/geometry.hpp:48,
                 from /path/to/modular-boost/boost/geometry.hpp:17,
                 from alias.cc:1:
/path/to/modular-boost/boost/geometry/geometries/point.hpp: In static
member function ‘static void
boost::geometry::index::detail::rtree::rstar::choose_split_axis_and_index_for_axis<Box,
AxisIndex, ElementIndexableTag>::apply
[...]
/path/to/modular-boost/boost/geometry/geometries/point.hpp:168:
warning: dereferencing pointer ‘<anonymous>’ does break
strict-aliasing rules
/path/to/modular-boost/boost/geometry/geometries/point.hpp:168:
warning: dereferencing pointer ‘<anonymous>’ does break
strict-aliasing rules
/path/to/modular-boost/boost/geometry/index/detail/rtree/rstar/redistribute_elements.hpp:121:
note: initialized from here
[etc.]

Any insight you could offer would be appreciated. Thanks!

 - Pat

#include <boost/geometry.hpp>
#include <boost/geometry/index/rtree.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>

namespace bg = boost::geometry;
namespace bgi = bg::index;

typedef bg::model::point<double, 2, bg::cs::cartesian> Point;
typedef bg::model::box<Point> Box;
typedef std::pair<Box, unsigned> Value;
typedef bgi::rtree<Value, bgi::rstar<16> > RTree;

void
foo()
{
  RTree rtree;
  Box b1(Point(0,0), Point(1,1));
  rtree.insert(Value(b1, 0));
}


Geometry list run by mateusz at loskot.net