Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#463 closed defect (fixed)

GEOS 3.3.0 does not compile on OS X 10.7 with clang

Reported by: vince Owned by: pramsey
Priority: major Milestone: 3.3.1
Component: Build/Install Version: 3.3.0
Severity: Critical Keywords: clang macos
Cc:

Description

GEOS 3.3.0 fails for different reasons on OS X 10.7 (Lion). With clang, this is a cast problem:

../../include/geos/geom/GeometryFactory.h:323:14: error: no matching conversion for functional-style cast from 'geos::geom::GeometryCollection *' to 'std::auto_ptr<Geometry>'
      return std::auto_ptr<Geometry>( createGeometryCollection() );
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.2.1/memory:189:7: note: candidate constructor not viable: cannot convert argument of incomplete type 'geos::geom::GeometryCollection *' to 'element_type *' (aka 'geos::geom::Geometry *')
      auto_ptr(element_type* __p = 0) throw() : _M_ptr(__p) { }
      ^
/usr/include/c++/4.2.1/memory:198:7: note: candidate constructor not viable: cannot convert argument of incomplete type 'geos::geom::GeometryCollection *' to 'std::auto_ptr<geos::geom::Geometry> &'
      auto_ptr(auto_ptr& __a) throw() : _M_ptr(__a.release()) { }
      ^
/usr/include/c++/4.2.1/memory:348:7: note: candidate constructor not viable: cannot convert argument of incomplete type 'geos::geom::GeometryCollection *' to 'auto_ptr_ref<element_type>'
      auto_ptr(auto_ptr_ref<element_type> __ref) throw()
      ^
/usr/include/c++/4.2.1/memory:211:9: note: candidate template ignored: failed template argument deduction
        auto_ptr(auto_ptr<_Tp1>& __a) throw() : _M_ptr(__a.release()) { }
        ^
In file included from ConvexHull.cpp:23:
../../include/geos/geom/GeometryFactory.h:346:14: error: no matching conversion for functional-style cast from 'geos::geom::GeometryCollection *' to 'std::auto_ptr<Geometry>'
      return std::auto_ptr<Geometry>( createGeometryCollection(fromGeoms) );
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.2.1/memory:189:7: note: candidate constructor not viable: cannot convert argument of incomplete type 'geos::geom::GeometryCollection *' to 'element_type *' (aka 'geos::geom::Geometry *')
      auto_ptr(element_type* __p = 0) throw() : _M_ptr(__p) { }
      ^
/usr/include/c++/4.2.1/memory:198:7: note: candidate constructor not viable: cannot convert argument of incomplete type 'geos::geom::GeometryCollection *' to 'std::auto_ptr<geos::geom::Geometry> &'
      auto_ptr(auto_ptr& __a) throw() : _M_ptr(__a.release()) { }
      ^
/usr/include/c++/4.2.1/memory:348:7: note: candidate constructor not viable: cannot convert argument of incomplete type 'geos::geom::GeometryCollection *' to 'auto_ptr_ref<element_type>'
      auto_ptr(auto_ptr_ref<element_type> __ref) throw()
      ^
/usr/include/c++/4.2.1/memory:211:9: note: candidate template ignored: failed template argument deduction
        auto_ptr(auto_ptr<_Tp1>& __a) throw() : _M_ptr(__a.release()) { }
        ^
In file included from ConvexHull.cpp:23:
../../include/geos/geom/GeometryFactory.h:351:14: error: no matching conversion for functional-style cast from 'geos::geom::MultiPolygon *' to 'std::auto_ptr<Geometry>'
      return std::auto_ptr<Geometry>( createMultiPolygon(fromGeoms) );
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.2.1/memory:189:7: note: candidate constructor not viable: cannot convert argument of incomplete type 'geos::geom::MultiPolygon *' to 'element_type *' (aka 'geos::geom::Geometry *')
      auto_ptr(element_type* __p = 0) throw() : _M_ptr(__p) { }
      ^
/usr/include/c++/4.2.1/memory:198:7: note: candidate constructor not viable: cannot convert argument of incomplete type 'geos::geom::MultiPolygon *' to 'std::auto_ptr<geos::geom::Geometry> &'
      auto_ptr(auto_ptr& __a) throw() : _M_ptr(__a.release()) { }
      ^
/usr/include/c++/4.2.1/memory:348:7: note: candidate constructor not viable: cannot convert argument of incomplete type 'geos::geom::MultiPolygon *' to 'auto_ptr_ref<element_type>'
      auto_ptr(auto_ptr_ref<element_type> __ref) throw()
      ^
/usr/include/c++/4.2.1/memory:211:9: note: candidate template ignored: failed template argument deduction
        auto_ptr(auto_ptr<_Tp1>& __a) throw() : _M_ptr(__a.release()) { }
        ^
In file included from ConvexHull.cpp:23:
../../include/geos/geom/GeometryFactory.h:353:14: error: no matching conversion for functional-style cast from 'geos::geom::MultiLineString *' to 'std::auto_ptr<Geometry>'
      return std::auto_ptr<Geometry>( createMultiLineString(fromGeoms) );
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.2.1/memory:189:7: note: candidate constructor not viable: cannot convert argument of incomplete type 'geos::geom::MultiLineString *' to 'element_type *' (aka 'geos::geom::Geometry *')
      auto_ptr(element_type* __p = 0) throw() : _M_ptr(__p) { }
      ^
/usr/include/c++/4.2.1/memory:198:7: note: candidate constructor not viable: cannot convert argument of incomplete type 'geos::geom::MultiLineString *' to 'std::auto_ptr<geos::geom::Geometry> &'
      auto_ptr(auto_ptr& __a) throw() : _M_ptr(__a.release()) { }
      ^
/usr/include/c++/4.2.1/memory:348:7: note: candidate constructor not viable: cannot convert argument of incomplete type 'geos::geom::MultiLineString *' to 'auto_ptr_ref<element_type>'
      auto_ptr(auto_ptr_ref<element_type> __ref) throw()
      ^
/usr/include/c++/4.2.1/memory:211:9: note: candidate template ignored: failed template argument deduction
        auto_ptr(auto_ptr<_Tp1>& __a) throw() : _M_ptr(__a.release()) { }
        ^
In file included from ConvexHull.cpp:23:
../../include/geos/geom/GeometryFactory.h:355:14: error: no matching conversion for functional-style cast from 'geos::geom::MultiPoint *' to 'std::auto_ptr<Geometry>'
      return std::auto_ptr<Geometry>( createMultiPoint(fromGeoms) );
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.2.1/memory:189:7: note: candidate constructor not viable: cannot convert argument of incomplete type 'geos::geom::MultiPoint *' to 'element_type *' (aka 'geos::geom::Geometry *')
      auto_ptr(element_type* __p = 0) throw() : _M_ptr(__p) { }
      ^
/usr/include/c++/4.2.1/memory:198:7: note: candidate constructor not viable: cannot convert argument of incomplete type 'geos::geom::MultiPoint *' to 'std::auto_ptr<geos::geom::Geometry> &'
      auto_ptr(auto_ptr& __a) throw() : _M_ptr(__a.release()) { }
      ^
/usr/include/c++/4.2.1/memory:348:7: note: candidate constructor not viable: cannot convert argument of incomplete type 'geos::geom::MultiPoint *' to 'auto_ptr_ref<element_type>'
      auto_ptr(auto_ptr_ref<element_type> __ref) throw()
      ^
/usr/include/c++/4.2.1/memory:211:9: note: candidate template ignored: failed template argument deduction
        auto_ptr(auto_ptr<_Tp1>& __a) throw() : _M_ptr(__a.release()) { }
        ^
5 errors generated.

whereas with llvm-gcc, it seems a method is missing when generating the dynamic library:

Undefined symbols for architecture x86_64:
  "__ZNSt8auto_ptrIN4geos4geom8EnvelopeEEcvSt12auto_ptr_refIT_EIS2_EEv", referenced from:
      virtual thunk to geos::geom::GeometryCollection::computeEnvelopeInternal() constin GeometryCollection.o
  "std::auto_ptr<geos::geom::Envelope>::auto_ptr(std::auto_ptr_ref<geos::geom::Envelope>)", referenced from:
      virtual thunk to geos::geom::GeometryCollection::computeEnvelopeInternal() constin GeometryCollection.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

Attachments (1)

463.patch (1.7 KB ) - added by hobu 13 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 by vince, 13 years ago

PS : this supersedes #462 that I could not retrieve in the base.

comment:2 by hobu, 13 years ago

This patch fixes the clang issue but not the llvm-gcc one.

by hobu, 13 years ago

Attachment: 463.patch added

comment:3 by hobu, 13 years ago

Pull down this patch and configure with

./configure CC=/usr/bin/clang CXX=/usr/bin/clang++
make
make install

comment:4 by strk, 13 years ago

It's odd that the include lines alone didn't fix the build. Do you confirm they didn't ?

I wouldn't expect a dynamic_cast to be required for upcasts, once the inheritance chain is known.

comment:5 by hobu, 13 years ago

I'll tweak this a bit to try to get rid of the casts. I agree they are not desired, but I thought it might be something that is only related to clang.

comment:6 by vince, 13 years ago

Resolution: fixed
Status: newclosed

Great! At least for me it works. It spits warnings about struct being defined as class, but nothing more serious. Thanks for this patch, I am going to commit it right away into Macports.

comment:7 by vince, 13 years ago

Resolution: fixed
Status: closedreopened

Oops. I forgot there remains the llvm-gcc case, though (same error with the old Apple gcc4.2)

comment:8 by hobu, 13 years ago

Let Sandro (strk) target and close tickets, as he is coordinating GEOS development.

I will make another patch attempt without the casts shortly.

comment:9 by vince, 13 years ago

Sandro Santilli ? Well, I then postpone the Macports commit until I could test your second patch. Thanks again, Vincent

comment:10 by hobu, 13 years ago

Indeed the casts are not needed. Applied in r3470.

comment:11 by strk, 13 years ago

Keywords: llvm-gcc removed
Resolution: fixed
Status: reopenedclosed
Summary: GEOS 3.3.0 does not compile on OS X 10.7, neither with clang nor with llvm-gccGEOS 3.3.0 does not compile on OS X 10.7 with clang

Backported in r3471. Please file another ticket for llvm-gcc

comment:12 by vince, 13 years ago

Ok, I'll do that. Meanwhile I will commit the updated patch into Macports and force a change from llvm-gcc4.2 to clang. Thanks for the patch again, the solution was simple, but I wasn’t able to figure it out.

Note: See TracTickets for help on using tickets.