Bug#1008036: apt: FTBFS with gcc-12
Source: apt
Version: 2.4.2
Tags: ftbfs patch
User: helmutg@debian.org
Usertags: rebootstrap
apt fails to build from source when using gcc-12. The issues roughly
are:
* Use of std::array without including #include <array>.
* Use of deprecated std::iterator (twice).
* Use of make_pair without std:: namespace.
Please consider applying the attached patch. I'll be cherry-picking this
into rebootstrap now, so there is no urgency from my side.
Helmut
diff --minimal -Nru apt-2.4.2/apt-pkg/cacheiterators.h apt-2.4.2+nmu1/apt-pkg/cacheiterators.h
--- apt-2.4.2/apt-pkg/cacheiterators.h 2022-03-17 09:17:27.000000000 +0100
+++ apt-2.4.2+nmu1/apt-pkg/cacheiterators.h 2022-03-21 05:31:39.000000000 +0100
@@ -44,8 +44,7 @@
// abstract Iterator template /*{{{*/
/* This template provides the very basic iterator methods we
need to have for doing some walk-over-the-cache magic */
-template<typename Str, typename Itr> class APT_PUBLIC pkgCache::Iterator :
- public std::iterator<std::forward_iterator_tag, Str> {
+template<typename Str, typename Itr> class APT_PUBLIC pkgCache::Iterator {
/** \brief Returns the Pointer for this struct in the owner
* The implementation of this method should be pretty short
* as it will only return the Pointer into the mmap stored
@@ -61,6 +60,12 @@
pkgCache *Owner;
public:
+ // iterator_traits
+ using iterator_category = std::forward_iterator_tag;
+ using value_type = Str;
+ using difference_type = std::ptrdiff_t;
+ using pointer = Str*;
+ using reference = Str&;
// Iteration
inline bool end() const {return Owner == 0 || S == OwnerPointer();}
diff --minimal -Nru apt-2.4.2/apt-pkg/cacheset.h apt-2.4.2+nmu1/apt-pkg/cacheset.h
--- apt-2.4.2/apt-pkg/cacheset.h 2022-03-17 09:17:27.000000000 +0100
+++ apt-2.4.2+nmu1/apt-pkg/cacheset.h 2022-03-21 05:31:39.000000000 +0100
@@ -203,12 +203,16 @@
}; /*}}}*/
// Iterator templates for our Containers /*{{{*/
template<typename Interface, typename Master, typename iterator_type, typename container_iterator, typename container_value> class Container_iterator_base :
- public std::iterator<typename std::iterator_traits<container_iterator>::iterator_category, container_value>,
public Interface::template iterator_base<iterator_type>
{
protected:
container_iterator _iter;
public:
+ using iterator_category = typename std::iterator_traits<container_iterator>::iterator_category;
+ using value_type = container_value;
+ using difference_type = std::ptrdiff_t;
+ using pointer = container_value*;
+ using reference = container_value&;
explicit Container_iterator_base(container_iterator const &i) : _iter(i) {}
inline container_value operator*(void) const { return static_cast<iterator_type const*>(this)->getType(); };
operator container_iterator(void) const { return _iter; }
diff --minimal -Nru apt-2.4.2/apt-pkg/depcache.cc apt-2.4.2+nmu1/apt-pkg/depcache.cc
--- apt-2.4.2/apt-pkg/depcache.cc 2022-03-17 09:17:27.000000000 +0100
+++ apt-2.4.2+nmu1/apt-pkg/depcache.cc 2022-03-21 05:31:39.000000000 +0100
@@ -2056,7 +2056,7 @@
if (itsFine == false)
{
// change the candidate
- Changed.push_back(make_pair(V, TargetVer));
+ Changed.push_back(std::make_pair(V, TargetVer));
if (SetCandidateRelease(V, TargetRel, Changed) == false)
{
if (stillOr == false)
diff --minimal -Nru apt-2.4.2/debian/changelog apt-2.4.2+nmu1/debian/changelog
--- apt-2.4.2/debian/changelog 2022-03-17 09:17:27.000000000 +0100
+++ apt-2.4.2+nmu1/debian/changelog 2022-03-21 05:31:39.000000000 +0100
@@ -1,3 +1,10 @@
+apt (2.4.2+nmu1) UNRELEASED; urgency=medium
+
+ * Non-maintainer upload.
+ * Fix FTBFS with gcc-12. (Closes: #-1)
+
+ -- Helmut Grohne <helmut@subdivi.de> Mon, 21 Mar 2022 05:31:39 +0100
+
apt (2.4.2) unstable; urgency=medium
[ Frans Spiesschaert ]
diff --minimal -Nru apt-2.4.2/test/interactive-helper/aptwebserver.cc apt-2.4.2+nmu1/test/interactive-helper/aptwebserver.cc
--- apt-2.4.2/test/interactive-helper/aptwebserver.cc 2022-03-17 09:17:27.000000000 +0100
+++ apt-2.4.2+nmu1/test/interactive-helper/aptwebserver.cc 2022-03-21 05:31:07.000000000 +0100
@@ -22,6 +22,7 @@
#include <unistd.h>
#include <algorithm>
+#include <array>
#include <fstream>
#include <iostream>
#include <list>
Reply to: