From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 114644 invoked by alias); 14 Nov 2019 02:56:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 114633 invoked by uid 89); 14 Nov 2019 02:56:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Nov 2019 02:56:09 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 435BD203A6; Wed, 13 Nov 2019 21:56:07 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id 12DA920339 for ; Wed, 13 Nov 2019 21:56:06 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id E2F1E20AF6 for ; Wed, 13 Nov 2019 21:56:05 -0500 (EST) X-Gerrit-PatchSet: 1 Date: Thu, 14 Nov 2019 02:56:00 -0000 From: "Simon Marchi (Code Review)" To: gdb-patches@sourceware.org Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] gdb: fix build error in unittests/vec-utils-selftests.c X-Gerrit-Change-Id: I323361b1c120bf8525613b74e7e5983910e002df X-Gerrit-Change-Number: 626 X-Gerrit-ChangeURL: X-Gerrit-Commit: 0d0ee819ea178b2cf9e603ec656548c96a216f61 References: Reply-To: simon.marchi@polymtl.ca, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/3.0.3-76-gf8b6da0ab5 Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2019-11/txt/msg00372.txt.bz2 Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/626 ...................................................................... gdb: fix build error in unittests/vec-utils-selftests.c When building with gcc 9.2.0, I get the following build error: In file included from /home/simark/src/binutils-gdb/gdb/unittests/vec-utils-selftests.c:23: /home/simark/src/binutils-gdb/gdb/gdbsupport/gdb_vecs.h: In instantiation of ‘T unordered_remove(std::__debug::vector&, typename std::__debug::vector::iterator) [with T = selftests::vector_utils_tests::unordered_remove_tests()::obj; typename std::__debug::vector::iterator = __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator > >, std::__debug::vector, std::random_access_iterator_tag>]’: /home/simark/src/binutils-gdb/gdb/unittests/vec-utils-selftests.c:53:26: required from here /home/simark/src/binutils-gdb/gdb/gdbsupport/gdb_vecs.h:53:5: error: implicitly-declared ‘selftests::vector_utils_tests::unordered_remove_tests()::obj::obj(const selftests::vector_utils_tests::unordered_remove_tests()::obj&)’ is deprecated [-Werror=deprecated-copy] 53 | T removed = std::move (*it); | ^~~~~~~ /home/simark/src/binutils-gdb/gdb/unittests/vec-utils-selftests.c:41:10: note: because ‘selftests::vector_utils_tests::unordered_remove_tests()::obj’ has user-provided ‘selftests::vector_utils_tests::unordered_remove_tests()::obj& selftests::vector_utils_tests::unordered_remove_tests()::obj::operator=(const selftests::vector_utils_tests::unordered_remove_tests()::obj&)’ 41 | obj &operator= (const obj &other) | ^~~~~~~~ In file included from /home/simark/src/binutils-gdb/gdb/unittests/vec-utils-selftests.c:23: /home/simark/src/binutils-gdb/gdb/gdbsupport/gdb_vecs.h:58:10: error: implicitly-declared ‘selftests::vector_utils_tests::unordered_remove_tests()::obj::obj(const selftests::vector_utils_tests::unordered_remove_tests()::obj&)’ is deprecated [-Werror=deprecated-copy] 58 | return removed; | ^~~~~~~ /home/simark/src/binutils-gdb/gdb/unittests/vec-utils-selftests.c:41:10: note: because ‘selftests::vector_utils_tests::unordered_remove_tests()::obj’ has user-provided ‘selftests::vector_utils_tests::unordered_remove_tests()::obj& selftests::vector_utils_tests::unordered_remove_tests()::obj::operator=(const selftests::vector_utils_tests::unordered_remove_tests()::obj&)’ 41 | obj &operator= (const obj &other) | ^~~~~~~~ I think gcc is just trying to be nice and recommends the good practice of providing a copy constructor if an assignment operator is provided. Silence the warning by providing that copy constructor. Change-Id: I323361b1c120bf8525613b74e7e5983910e002df --- M gdb/unittests/vec-utils-selftests.c 1 file changed, 9 insertions(+), 0 deletions(-) diff --git a/gdb/unittests/vec-utils-selftests.c b/gdb/unittests/vec-utils-selftests.c index 823bbb6..d0ead99 100644 --- a/gdb/unittests/vec-utils-selftests.c +++ b/gdb/unittests/vec-utils-selftests.c @@ -38,6 +38,15 @@ { std::vector var; + obj() = default; + + /* gcc complains if we provide an assignment operator but no copy + constructor, so provide even if don't really care for this test. */ + obj(const obj &other) + { + this->var = other.var; + } + obj &operator= (const obj &other) { if (this == &other) -- Gerrit-Project: binutils-gdb Gerrit-Branch: master Gerrit-Change-Id: I323361b1c120bf8525613b74e7e5983910e002df Gerrit-Change-Number: 626 Gerrit-PatchSet: 1 Gerrit-Owner: Simon Marchi Gerrit-MessageType: newchange