diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2019-11-14 06:50:20 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2019-11-14 06:51:30 -0500 |
commit | 4b09bb2eff20913fe5057b50b9509eecf14f4877 (patch) | |
tree | 37571ca90efb2d2044fe68dbd14ab171c152b2fd | |
parent | 6aa385b96f0fddcf152c88f29e1145f3f618748c (diff) | |
download | gdb-4b09bb2eff20913fe5057b50b9509eecf14f4877.zip gdb-4b09bb2eff20913fe5057b50b9509eecf14f4877.tar.gz gdb-4b09bb2eff20913fe5057b50b9509eecf14f4877.tar.bz2 |
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<T>&, typename std::__debug::vector<T>::iterator) [with T = selftests::vector_utils_tests::unordered_remove_tests()::obj; typename std::__debug::vector<T>::iterator = __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<selftests::vector_utils_tests::unordered_remove_tests()::obj*, std::__cxx1998::vector<selftests::vector_utils_tests::unordered_remove_tests()::obj, std::allocator<selftests::vector_utils_tests::unordered_remove_tests()::obj> > >, std::__debug::vector<selftests::vector_utils_tests::unordered_remove_tests()::obj>, 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.
gdb/ChangeLog:
* unittests/vec-utils-selftests.c (unordered_remove_tests::obj):
Provide explicit default and copy constructor.
Change-Id: I323361b1c120bf8525613b74e7e5983910e002df
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/unittests/vec-utils-selftests.c | 9 |
2 files changed, 14 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8be8efb..719574f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-11-14 Simon Marchi <simon.marchi@polymtl.ca> + + * unittests/vec-utils-selftests.c (unordered_remove_tests::obj): + Provide explicit default and copy constructor. + 2019-11-14 Philippe Waroquiers <philippe.waroquiers@skynet.be> * python/py-finishbreakpoint.c (gdbpy_breakpoint_created): diff --git a/gdb/unittests/vec-utils-selftests.c b/gdb/unittests/vec-utils-selftests.c index 823bbb6..5149091 100644 --- a/gdb/unittests/vec-utils-selftests.c +++ b/gdb/unittests/vec-utils-selftests.c @@ -38,6 +38,15 @@ unordered_remove_tests () { std::vector<void *> var; + obj() = default; + + /* gcc complains if we provide an assignment operator but no copy + constructor, so provide one 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) |