After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 753123 - Don't use deprecated std::auto_ptr
Don't use deprecated std::auto_ptr
Status: RESOLVED FIXED
Product: libxml++
Classification: Bindings
Component: General
2.39.x
Other All
: Normal normal
: ---
Assigned To: Christophe de Vienne
Christophe de Vienne
Depends on:
Blocks:
 
 
Reported: 2015-08-01 08:15 UTC by Kjell Ahlstedt
Modified: 2015-09-21 09:15 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Kjell Ahlstedt 2015-08-01 08:15:16 UTC
libxml++ uses the deprecated std::auto_ptr in the files

  libxml++/relaxngschema.h
  libxml++/xsdschema.h
  libxml++/parsers/parser.cc
  libxml++/parsers/saxparser.h
  libxml++/parsers/textreader.h
  libxml++/validators/relaxngvalidator.[h|cc]
  libxml++/validators/validator.cc
  libxml++/validators/xsdvalidator.[h|cc]

With gcc 5.1 and -std=c++11 -Wdeprecated-declarations these uses generate
warnings. See glibmm bug 748630.

std::auto_ptr shall be replaced by std::unique_ptr, but replacing in the
header files will break ABI.
Comment 1 Kjell Ahlstedt 2015-08-02 14:52:25 UTC
I have replaced auto_ptr in the .cc files. The header files remain. They will
have to wait until we break ABI. We will perhaps have to do that in a few years.
In http://en.cppreference.com/w/cpp/memory auto_ptr is marked "(until C++17)".
Comment 2 Murray Cumming 2015-08-12 11:26:01 UTC
Do you see these warnings during a normal --enable-warnings=fatal build. I don't see them even with this change, with g++ 4.9.2:

 MM_ARG_ENABLE_WARNINGS([LIBXMLXX_WXXFLAGS],
         [-Wall],
-        [-pedantic -Wall -Wextra -Wformat-security -Wshadow -Wno-long-long],
+        [-pedantic -Wall -Wextra -Wformat-security -Wshadow -Wdeprecated-declarations -Wno-long-long],
         [G GLIBMM SIGCXX])
Comment 3 Kjell Ahlstedt 2015-08-12 17:27:27 UTC
No, I don't get these warnings, not even with -Wdeprecated-declarations.
I also use g++ 4.9.2. According to bug 748630, g++ 5.1 warns.
Comment 4 Gert 2015-09-04 11:14:31 UTC
I'd like to chime in that g++5 introduces an ABI change in libstdc++ with c++11 enabled. Specifically, the std::string class now resides in the __cxx11 namespace if something is compiled with the define _GLIBCXX_USE_CXX11_ABI. Since std::string is used in the headers of libxml++, its ABI will therefore break, and IMHO it would be a good idea to move from auto_ptr to unique_ptr if compiled with the _GLIBCXX_USE_CXX11_ABI flag (which is the default for g++-5). 

cf: https://developerblog.redhat.com/2015/02/05/gcc5-and-the-c11-abi/
Comment 5 Kjell Ahlstedt 2015-09-04 14:39:56 UTC
Link to the description of _GLIBCXX_USE_CXX11_ABI:
https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html

The naive fix is to change

  std::auto_ptr<Impl> pimpl_;

to

  #if _GLIBCXX_USE_CXX11_ABI > 0
    std::unique_ptr<Impl> pimpl_;
  #else
    std::auto_ptr<Impl> pimpl_;
  #endif

That would not work if libxml++ is built with one value of _GLIBCXX_USE_CXX11_ABI,
and an application program is compiled with another value.

The ABI break caused by a change in _GLIBCXX_USE_CXX11_ABI was discussed
extensively on the gtkmm-list starting in June with
https://mail.gnome.org/archives/gtkmm-list/2015-June/msg00003.html.
Another intersting post:
https://mail.gnome.org/archives/gtkmm-list/2015-August/msg00005.html

I think the result of that long thread is that the mm packages (glibmm, gtkmm,
libxml++, etc.) will only support the default value of _GLIBCXX_USE_CXX11_ABI.
When a new version of a Linux distribution changes the default value from
0 to 1, there will be lots of ABI breaks in that distribution, but it won't
be our fault. So the naive fix is probably ok, but I suppose it only works
for g++, and probably for clang++. What about MSVC?
Comment 6 Gert 2015-09-04 15:11:08 UTC
FYI: Debian, Ubuntu, and Fedora are doing this transition right now.
Comment 7 Kjell Ahlstedt 2015-09-04 16:37:59 UTC
Does that mean that it's too late to coordinate the change from auto_ptr to
unique_ptr with the increase of _GLIBCXX_USE_CXX11_ABI from 0 to 1?
If for instance Ubuntu 15.10 will define _GLIBCXX_USE_CXX11_ABI = 1?
I guess that patches added to git now and included in a future libxml++ version
will not be included in Ubuntu 15.10.
Comment 8 Gert 2015-09-04 17:10:03 UTC
You are probably right for Ubuntu 15.10 [1]. 

Unfortunately, it seems that in Ubuntu the ABI change is not indicated by the package name. In Debian all packages that needed transition to the new ABI and did not change their name by another pending SO-name change have now a v5 suffix in the library package name, e.g. [2], and yes, libxml++ already passed that stage. 

However, in Debian the libxml++ package is part of more transitions [3], and providing a new version with the new unique_ptr ABI would probably be considered soon, and if the new version makes it into into Debian/testing then it will also make it into Ubuntu 16.04 (IMO), which is the next LTS version. 

[1] https://wiki.ubuntu.com/WilyWerewolf/ReleaseSchedule
[2] https://packages.debian.org/sid/libxml++2.6-2v5
[3] https://packages.qa.debian.org/libx/libxml++2.6.html
Comment 9 Kjell Ahlstedt 2015-09-06 14:24:29 UTC
There will probably be a new ABI-breaking release within the next few months.

https://mail.gnome.org/archives/libxmlplusplus-list/2015-September/msg00001.html
Comment 10 Kjell Ahlstedt 2015-09-17 13:28:42 UTC
I have replaced the remaining auto_ptr by unique_ptr.
The fix will be included in a future ABI-breaking release.
Comment 11 Murray Cumming 2015-09-21 06:52:40 UTC
I've tried the new version in Glom and everything seems fine. Thanks. Maybe we can do a first release some time in the next few weeks, avoiding confusing packagers of the current next distro versions.
Comment 12 Kjell Ahlstedt 2015-09-21 09:15:13 UTC
Yes, an ABI/API-breaking release in a few weeks is a realistic goal.
There are many TODO comments suggesting ABI-breaking modifications, some
trivial, others not quite trivial.