Boost logo

Geometry :

Subject: Re: [geometry] GCC 4.4.7 and strict aliasing warnings
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2014-10-27 20:47:59


Hi,

Patrick J. Lopresti wrote:
> (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.

Which version of Boost are you using? 1.56?

Is the compiler complaining about the line 121 in this file:
https://github.com/boostorg/geometry/blob/geometry-1.56.0/include/boost/geometry/index/detail/rtree/rstar/redistribute_elements.hpp
?
So this:

     choosen_index=parameters.get_min_elements();

Here a static method is called (see line 139
https://github.com/boostorg/geometry/blob/geometry-1.56.0/include/boost/geometry/index/parameters.hpp)
If you wanted to play with it, you could remove static keywords in your
local copy and see if the warning was still there.

In the file
https://github.com/boostorg/geometry/blob/geometry-1.56.0/include/boost/geometry/geometries/point.hpp,
line 168:

     returnp.templateget<Dimension>();

Here a member function template instantiation is called.

If the compiler complains about the above it's probably a bug in the
compiler.

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

Maybe related to this:
http://stackoverflow.com/questions/15520642/using-stdmap-gives-warning-dereferencing-pointer-anonymous-does-break-str
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39390

Regards,
Adam

> $ /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 mailing list
> Geometry_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/geometry


Geometry list run by mateusz at loskot.net