Source: cupt
Version: 2.2.1
Justification: ftbfs with g++ 4.6
Tags: patch

Hi,

Trying to build cupt with g++ 4.6 (after tweaking CMakeLists.txt to
use it), I get:

| [  4%] Building CXX object 
cpp/lib/CMakeFiles/cupt2.dir/src/internal/nativeresolver/impl.cpp.o
| [...]/cpp/lib/src/internal/nativeresolver/impl.cpp: In member function ‘void 
cupt::internal::NativeResolverImpl::__require_strict_relation_expressions()’:
| [...]/cpp/lib/src/internal/nativeresolver/impl.cpp:407:62: error: cannot bind 
‘cupt::cache::RelationLine’ lvalue to ‘cupt::cache::RelationLine&&’
| [...]/cpp/lib/include/cupt/cache/relation.hpp:195:16: error:   initializing 
argument 1 of ‘cupt::cache::RelationLine& 
cupt::cache::RelationLine::operator=(cupt::cache::RelationLine&&)’
| [...]/cpp/lib/src/internal/nativeresolver/impl.cpp:408:61: error: cannot bind 
‘cupt::cache::RelationLine’ lvalue to ‘cupt::cache::RelationLine&&’
| [...]/cpp/lib/include/cupt/cache/relation.hpp:195:16: error:   initializing 
argument 1 of ‘cupt::cache::RelationLine& 
cupt::cache::RelationLine::operator=(cupt::cache::RelationLine&&)’
| [...]/cpp/lib/src/internal/nativeresolver/impl.cpp: In member function ‘void 
cupt::internal::NativeResolverImpl::__validate_element(cupt::internal::Solution&,
 const Element*, size_t)’:
| [...]/cpp/lib/src/internal/nativeresolver/impl.cpp:805:67: error: no matching 
function for call to ‘cupt::internal::PackageEntry::PackageEntry(const 
cupt::internal::PackageEntry&)’

and many other errors of the same kind.  How about this patch?

-- >8 --
Subject: lib: do not suppress default copy constructors and assignment operators

Building cupt with g++ 4.6 produces some errors due to missing
copy-assignment operators and copy constructors.

The C++ standard (n3242, section special.class.copy "Copying and
moving class objects", paragraph 8) explains:

        If the class definition does not explicitly declare a copy
        constructor, there is no user-declared move constructor, and
        there is no user-declared move assignment operator, a copy
        constructor is implicitly declared as defaulted.

In other words, if we declare _any_ move constructor or move
assignment operator, the default copy constructor is not guaranteed to
be present.  (Likewise for the default copy-assignment operator.)

Worse, most of the move operations we provide are superfluous, since
they just call std::move to convert "operand.member" from an lvalue to
an xvalue, and members of an object referred to by rvalue reference
are already xvalues.  Simplify by using the implicit definitions that
accomplish the same thing (but to be cautious, explicitly declare that
we are doing so).

The only exception is cupt::internal::PackageEntry, whose rvalue
operations explicitly call std::vector::swap.  That is probably not
needed, either, since std::vector provides rvalue operations, too, but
to be conservative, this patch leaves it alone.

Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
 cpp/lib/include/cupt/cache/relation.hpp          |   28 ++++++++++++++--------
 cpp/lib/src/cache/relation.cpp                   |   15 -----------
 cpp/lib/src/internal/nativeresolver/solution.hpp |    2 +
 3 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/cpp/lib/include/cupt/cache/relation.hpp 
b/cpp/lib/include/cupt/cache/relation.hpp
index f6f1f965..acf226e3 100644
--- a/cpp/lib/include/cupt/cache/relation.hpp
+++ b/cpp/lib/include/cupt/cache/relation.hpp
@@ -56,8 +56,10 @@ struct CUPT_API Relation
         * @param input pair of begin iterator and end iterator of stringified 
relation
         */
        explicit Relation(pair< string::const_iterator, string::const_iterator 
> input);
-       /// constructor from rvalue reference
-       Relation(Relation&&);
+       Relation(Relation&&) = default;
+       Relation(const Relation&) = default;
+       Relation& operator=(Relation&&) = default;
+       Relation& operator=(const Relation&) = default;
        /// destructor
        virtual ~Relation();
        /// gets the string reprentation
@@ -101,7 +103,10 @@ struct CUPT_API ArchitecturedRelation: public Relation
         * architectured relation
         */
        ArchitecturedRelation(pair< string::const_iterator, 
string::const_iterator > input);
-       ArchitecturedRelation(ArchitecturedRelation&&);
+       ArchitecturedRelation(ArchitecturedRelation&&) = default;
+       ArchitecturedRelation(const ArchitecturedRelation&) = default;
+       ArchitecturedRelation& operator=(ArchitecturedRelation&&) = default;
+       ArchitecturedRelation& operator=(const ArchitecturedRelation&) = 
default;
        string toString() const;
 };
 
@@ -131,8 +136,10 @@ struct CUPT_API RelationExpression: public vector< 
Relation >
         * representation
         */
        explicit RelationExpression(pair< string::const_iterator, 
string::const_iterator > input);
-       /// copy constructor from rvalue reference
-       RelationExpression(RelationExpression&&);
+       RelationExpression(RelationExpression&&) = default;
+       RelationExpression(const RelationExpression&) = default;
+       RelationExpression& operator=(RelationExpression&&) = default;
+       RelationExpression& operator=(const RelationExpression&) = default;
        /// destructor
        virtual ~RelationExpression();
 };
@@ -161,9 +168,10 @@ struct CUPT_API ArchitecturedRelationExpression: public 
vector< ArchitecturedRel
         * representation
         */
        ArchitecturedRelationExpression(pair< string::const_iterator, 
string::const_iterator > input);
-       /// copy constructor from rvalue reference
-       ArchitecturedRelationExpression(ArchitecturedRelationExpression&&);
-       /// destructor
+       ArchitecturedRelationExpression(ArchitecturedRelationExpression&&) = 
default;
+       ArchitecturedRelationExpression(const ArchitecturedRelationExpression&) 
= default;
+       ArchitecturedRelationExpression& 
operator=(ArchitecturedRelationExpression&&) = default;
+       ArchitecturedRelationExpression& operator=(const 
ArchitecturedRelationExpression&) = default;
        virtual ~ArchitecturedRelationExpression();
 };
 
@@ -191,8 +199,8 @@ struct CUPT_API RelationLine: public vector< 
RelationExpression >
         * representation
         */
        explicit RelationLine(pair< string::const_iterator, 
string::const_iterator > input);
-       /// operator= from the rvalue reference
        RelationLine& operator=(RelationLine&& other);
+       RelationLine& operator=(const RelationLine&) = default;
        /// destructor
        virtual ~RelationLine();
 };
@@ -221,8 +229,8 @@ struct CUPT_API ArchitecturedRelationLine: public vector< 
ArchitecturedRelationE
         * representation
         */
        explicit ArchitecturedRelationLine(pair< string::const_iterator, 
string::const_iterator > input);
-       /// operator= from the rvalue reference
        ArchitecturedRelationLine& operator=(ArchitecturedRelationLine&&);
+       ArchitecturedRelationLine& operator=(const ArchitecturedRelationLine&) 
= default;
        /// converts to RelationLine given system architecture
        /**
         * Filters ArchitecturedRelationLine using binary system architecture.
diff --git a/cpp/lib/src/cache/relation.cpp b/cpp/lib/src/cache/relation.cpp
index ce7ed61c..5f721cda 100644
--- a/cpp/lib/src/cache/relation.cpp
+++ b/cpp/lib/src/cache/relation.cpp
@@ -160,12 +160,6 @@ Relation::Relation(const string& unparsed)
        __init(unparsed.begin(), unparsed.end());
 }
 
-Relation::Relation(Relation&& other)
-       : packageName(std::move(other.packageName)),
-       relationType(other.relationType),
-       versionString(std::move(other.versionString))
-{}
-
 Relation::~Relation()
 {}
 
@@ -248,11 +242,6 @@ ArchitecturedRelation::ArchitecturedRelation(
        __init(std::find(input.first, input.second, '['), input.second);
 }
 
-ArchitecturedRelation::ArchitecturedRelation(ArchitecturedRelation&& other)
-       : Relation(static_cast< Relation&& >(other)),
-       architectureFilters(std::move(other.architectureFilters))
-{}
-
 string ArchitecturedRelation::toString() const
 {
        static const string openingBracket = "[";
@@ -417,10 +406,6 @@ RelationExpressionType::RelationExpressionType(const 
string& expression) \
        __init(expression.begin(), expression.end()); \
 } \
 \
-RelationExpressionType::RelationExpressionType(RelationExpressionType&& other) 
\
-       : vector< UnderlyingElement >(std::move(other)) \
-{} \
-\
 RelationExpressionType::~RelationExpressionType() \
 {} \
  \
diff --git a/cpp/lib/src/internal/nativeresolver/solution.hpp 
b/cpp/lib/src/internal/nativeresolver/solution.hpp
index 88778650..6fe07930 100644
--- a/cpp/lib/src/internal/nativeresolver/solution.hpp
+++ b/cpp/lib/src/internal/nativeresolver/solution.hpp
@@ -77,8 +77,10 @@ struct PackageEntry
 
        PackageEntry();
        PackageEntry(PackageEntry&&);
+       PackageEntry(const PackageEntry&) = default;
 
        PackageEntry& operator=(PackageEntry&&);
+       PackageEntry& operator=(const PackageEntry&) = default;
 };
 
 class PackageEntryMap;
-- 
1.7.7.1




--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to