Opened 8 years ago

Closed 5 years ago

#785 closed defect (wontfix)

g++ 6 auto_ptr

Reported by: rsbivand Owned by: geos-devel@…
Priority: minor Milestone: 3.8.0
Component: Default Version: 3.5.0
Severity: Unassigned Keywords:
Cc:

Description

The use of auto_ptr throws warnings in g++ 6 in Fedora 24, chiefly in XMLTester:

In file included from ../../include/geos/geom/Geometry.h:27:0,
                 from ../../include/geos/geom/Point.h:26,
                 from XMLTester.cpp:27:
../../include/geos/geom/Envelope.h: At global scope:
../../include/geos/geom/Envelope.h:57:15: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
  typedef std::auto_ptr<Envelope> AutoPtr;
               ^~~~~~~~
In file included from /usr/include/c++/6.1.1/memory:81:0,
                 from ../../include/geos/geom/Envelope.h:29,
                 from ../../include/geos/geom/Geometry.h:27,
                 from ../../include/geos/geom/Point.h:26,
                 from XMLTester.cpp:27:
/usr/include/c++/6.1.1/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~

There are other wanings for other types of -W, such as the following, so it looks as though g++ 6 is stricter in checking:

WKTWriter.cpp: In member function ‘void geos::io::WKTWriter::appendPointTaggedText(const geos::geom::Coordinate*, int, geos::io::Writer*)’:
WKTWriter.cpp:239:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
     if( outputDimension == 3 && !old3D && coordinate != NULL )
     ^~
WKTWriter.cpp:242:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
  appendPointText(coordinate, level, writer);
  ^~~~~~~~~~~~~~~

Change History (8)

comment:1 by strk, 8 years ago

I'm afraid we are not ready to deprecate auto_ptr yet.

comment:2 by rouault, 8 years ago

auto_ptr and unique_ptr have very similar behaviour and API and can be used equivalently if you make basic uses of them (check the differences to see if you're not running into them)

In GDAL there's a driver making use of auto_ptr, and I've finally done

#if __cplusplus >= 201103L
#define UNIQUEPTR       std::unique_ptr
#else
#define UNIQUEPTR       std::auto_ptr
#endif

A bit ugly, but works fine.

in reply to:  2 comment:3 by mloskot, 8 years ago

Replying to rouault:

In GDAL there's a driver making use of auto_ptr, and I've finally done

#if __cplusplus >= 201103L
#define UNIQUEPTR       std::unique_ptr
#else
#define UNIQUEPTR       std::auto_ptr
#endif

For sake, typedef!

comment:4 by strk, 8 years ago

An uniqueptr typedef sounds like a good idea. Patches welcome !

comment:5 by mloskot, 8 years ago

I'd rather leave it as it is and wait until we can switch to c++0x/11 compilers and to std::unique_ptr only.

If GEOS switches to C++11, I will actively participate in the 'upgrade' refactoring.

Last edited 8 years ago by mloskot (previous) (diff)

comment:6 by strk, 8 years ago

Milestone: 3.5.13.5.2

Ticket retargeted after milestone closed

comment:7 by robe, 6 years ago

Milestone: 3.5.23.8.0

comment:8 by dbaston, 5 years ago

Resolution: wontfix
Status: newclosed

I think this can be considered closed now that current GEOS uses C++11, and we aren't going to backport C++11 features into stable branches.

Note: See TracTickets for help on using tickets.