<div dir="ltr"><div>Posted as a public service for future reference.</div><div><br></div>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:<div><br></div><div>----------------------------------------------</div><div><pre class="gmail-c-mrkdwn__pre" style="box-sizing:inherit;margin-top:4px;margin-bottom:4px;padding:8px;font-size:12px;line-height:1.50001;font-variant-ligatures:none;white-space:pre-wrap;word-break:normal;border-radius:4px;color:rgb(29,28,29);font-family:Monaco,Menlo,Consolas,"Courier New",monospace">[ 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 </pre><pre class="gmail-c-mrkdwn__pre" style="box-sizing:inherit;margin-top:4px;margin-bottom:4px;padding:8px;font-size:12px;line-height:1.50001;font-variant-ligatures:none;white-space:pre-wrap;word-break:normal;border-radius:4px;color:rgb(29,28,29);font-family:Monaco,Menlo,Consolas,"Courier New",monospace">------------------------------------</pre>It looks like this is a bug in gcc 11, as per this issue:</div><div><a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96003">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96003</a></div><div><br></div><div>One fix is to add a pragma to disable the warning in Geometry.h :</div><div><br></div> /// Make a deep-copy of this Geometry<br> std::unique_ptr<Geometry> clone() const { <div><div>#pragma GCC diagnostic push<br></div><div>#pragma GCC diagnostic ignored "-Wnonnull"<br> return std::unique_ptr<Geometry>(cloneImpl());<br>#pragma GCC diagnostic pop<br></div><div>}</div><div><br></div><div>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.</div><div><br></div><div><br></div><div><div><br></div></div></div></div>