GNOME Bugzilla – Bug 753123
Don't use deprecated std::auto_ptr
Last modified: 2015-09-21 09:15:13 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.
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)".
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])
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.
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/
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?
FYI: Debian, Ubuntu, and Fedora are doing this transition right now.
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.
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
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
I have replaced the remaining auto_ptr by unique_ptr. The fix will be included in a future ABI-breaking release.
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.
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.