[geos-devel] GEOS affected by bug in gcc-11 - with workarounds
Martin Davis
mtnclimb at gmail.com
Thu Sep 16 12:08:21 PDT 2021
Posted as a public service for future reference.
While recovering from upgrading my Mac to Big Sur (which is a
whoooole 'nother rant), I upgraded to gcc-11 (using Homebrew). Sadly,
compiling GEOS then threw the following error message:
----------------------------------------------
[ 29%] Building CXX object
CMakeFiles/geos.dir/src/operation/union/CoverageUnion.cpp.o
In file included from
/Users/mdavis/proj/geos/git/geos/src/operation/union/CascadedPolygonUnion.cpp:21:
In member function 'std::unique_ptr<geos::geom::Geometry>
geos::geom::Geometry::clone() const',
inlined from 'std::unique_ptr<geos::geom::Geometry>
geos::operation::geounion::CascadedPolygonUnion::unionSafe(const
geos::geom::Geometry*, const geos::geom::Geometry*) const' at
/Users/mdavis/proj/geos/git/geos/src/operation/union/CascadedPolygonUnion.cpp:128:26,
inlined from 'std::unique_ptr<geos::geom::Geometry>
geos::operation::geounion::CascadedPolygonUnion::binaryUnion(const
std::vector<const geos::geom::Geometry*>&, std::size_t, std::size_t)'
at /Users/mdavis/proj/geos/git/geos/src/operation/union/CascadedPolygonUnion.cpp:106:4:
/Users/mdavis/proj/geos/git/geos/include/geos/geom/Geometry.h:204:91:
error: 'this' pointer is null [-Werror=nonnull]
204 | std::unique_ptr<Geometry> clone() const { return
std::unique_ptr<Geometry>(cloneImpl()); }
|
^
[ 29%] Building CXX object
CMakeFiles/geos.dir/src/operation/union/OverlapUnion.cpp.o
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/geos.dir/src/operation/union/CascadedPolygonUnion.cpp.o]
Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/geos.dir/all] Error 2
make: *** [all] Error
------------------------------------
It looks like this is a bug in gcc 11, as per this issue:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96003
One fix is to add a pragma to disable the warning in Geometry.h :
/// Make a deep-copy of this Geometry
std::unique_ptr<Geometry> clone() const {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnonnull"
return std::unique_ptr<Geometry>(cloneImpl());
#pragma GCC diagnostic pop
}
However, I chose to downgrade to gcc-10 instead (thanks to Homebrew for
making this super easy!). Problem gone, and no ugly hack marring our
beautiful codebase.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geos-devel/attachments/20210916/63ca2e0e/attachment.html>
More information about the geos-devel
mailing list