|
Geometry : |
Subject: Re: [geometry] GCC 4.9.1 "may be used uninitialized" warnings
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2014-10-15 11:01:34
Hi Patrick,
Patrick J. Lopresti wrote:
> OK, I think I see it. In
> algorithms/detail/overlay/intersection_box_box.hpp, it looks like
> apply() returns false early (without initializing box_out) when the
> intervals do not intersect. But in
> index/detail/algorithms/intersection_content.hpp, the return value of
> geometry::intersection() is not checked, because the logic does not
> require it:
>
> if ( geometry::intersects(box1, box2) )
> {
> Box box_intersection;
> geometry::intersection(box1, box2, box_intersection); //
> return value ignored
> return detail::content(box_intersection);
> }
> return 0;
>
> I have confirmed that the warning vanishes if I rewrite the code like this:
>
> Box box_intersection;
> if ( geometry::intersection(box1, box2, box_intersection) )
> return detail::content(box_intersection);
> return 0;
>
> Are you folks amenable to this change to silence GCC, or do you fear
> the performance implications?
The version above seems to be slightly slower, around 5% for 1M points
on GCC 9.1 and MSVC 11.
Tested with libs/geometry/index/example/benchmark_experimental.cpp, FYI
this algorithm is used only in the R*-tree so you must uncomment it in
the benchmark to notice the change.
But this version seems to be ok:
if ( geometry::intersects(box1, box2) )
{
Box box_intersection;
if ( geometry::intersection(box1, box2, box_intersection) )
return detail::content(box_intersection);
}
and it's more robust.
So I'll change it. Thanks for suggestion.
Regards,
Adam
Geometry list run by mateusz at loskot.net