From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1984) id 0564D3945C0B; Fri, 17 Jul 2020 12:50:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0564D3945C0B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594990207; bh=k0RxcN02c1pN3U4zPDtgYdAk8jXeu0H6usvudDNYQfc=; h=From:To:Subject:Date:From; b=IYfm4DftGz5JeIy5i/RlCLvykvlAIfSlSh0t/4ep6qFPN0OVY2kANmTVM/gDmfBv4 p7VLp4f3XRxnL10JNwWsw2sUnwb0qJIBKSSygosUaoTVrYBYqBQdFtTI0PwtRi2LyT 5Yp5Avwr3pIK2GRC0vZh1JaFuYAPQJPPddoBUBm0= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tamar Christina To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/arm-struct-reorg-wip)] libstdc++: Fix LWG issues 3389 and 3390 X-Act-Checkin: gcc X-Git-Author: Patrick Palka X-Git-Refname: refs/vendors/ARM/heads/arm-struct-reorg-wip X-Git-Oldrev: 02ce382cd323097f9d02fbf91e0a3f59ebcd3d30 X-Git-Newrev: 99bbab9f77424c6387e7dfcba5c62937a8cff841 Message-Id: <20200717125007.0564D3945C0B@sourceware.org> Date: Fri, 17 Jul 2020 12:50:07 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jul 2020 12:50:07 -0000 https://gcc.gnu.org/g:99bbab9f77424c6387e7dfcba5c62937a8cff841 commit 99bbab9f77424c6387e7dfcba5c62937a8cff841 Author: Patrick Palka Date: Tue Feb 11 10:45:26 2020 -0500 libstdc++: Fix LWG issues 3389 and 3390 libstdc++-v3/ChangeLog: LWG 3389 and LWG 3390 * include/bits/stl_iterator.h (move_move_iterator): Use std::move when constructing the move_iterator with __i. (counted_iterator::counted_iterator): Use std::move when initializing M_current with __i. * testsuite/24_iterators/counted_iterator/lwg3389.cc: New test. * testsuite/24_iterators/move_iterator/lwg3390.cc: New test. Diff: --- libstdc++-v3/ChangeLog | 10 ++++ libstdc++-v3/include/bits/stl_iterator.h | 4 +- .../24_iterators/counted_iterator/lwg3389.cc | 66 ++++++++++++++++++++++ .../24_iterators/move_iterator/lwg3390.cc | 66 ++++++++++++++++++++++ 4 files changed, 144 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 922c715c838..cc4cfb7da0f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2020-02-12 Patrick Palka + + LWG 3389 and LWG 3390 + * include/bits/stl_iterator.h (move_move_iterator): Use std::move when + constructing the move_iterator with __i. + (counted_iterator::counted_iterator): Use std::move when initializing + M_current with __i. + * testsuite/24_iterators/counted_iterator/lwg3389.cc: New test. + * testsuite/24_iterators/move_iterator/lwg3390.cc: New test. + 2020-02-12 Sandra Loosemore PR libstdc++/79193 diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index 4e70672924b..fc9d442b475 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -1375,7 +1375,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline _GLIBCXX17_CONSTEXPR move_iterator<_Iterator> make_move_iterator(_Iterator __i) - { return move_iterator<_Iterator>(__i); } + { return move_iterator<_Iterator>(std::move(__i)); } template __n) - : _M_current(__i), _M_length(__n) + : _M_current(std::move(__i)), _M_length(__n) { __glibcxx_assert(__n >= 0); } template diff --git a/libstdc++-v3/testsuite/24_iterators/counted_iterator/lwg3389.cc b/libstdc++-v3/testsuite/24_iterators/counted_iterator/lwg3389.cc new file mode 100644 index 00000000000..cf74fd47bec --- /dev/null +++ b/libstdc++-v3/testsuite/24_iterators/counted_iterator/lwg3389.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +#include + +using __gnu_test::test_range; +using __gnu_test::input_iterator_wrapper; + +template +struct move_only_wrapper : input_iterator_wrapper +{ + using input_iterator_wrapper::input_iterator_wrapper; + + move_only_wrapper() + : input_iterator_wrapper(nullptr, nullptr) + { } + + move_only_wrapper(const move_only_wrapper&) = delete; + move_only_wrapper& + operator=(const move_only_wrapper&) = delete; + + move_only_wrapper(move_only_wrapper&&) = default; + move_only_wrapper& + operator=(move_only_wrapper&&) = default; + + using input_iterator_wrapper::operator++; + + move_only_wrapper& + operator++() + { + input_iterator_wrapper::operator++(); + return *this; + } +}; + +static_assert(std::input_iterator>); +static_assert(!std::forward_iterator>); +static_assert(!std::copyable>); + +// LWG 3389 +void +test01() +{ + int x[] = {1,2,3,4}; + test_range rx(x); + auto it = std::counted_iterator(rx.begin(), 2); +} diff --git a/libstdc++-v3/testsuite/24_iterators/move_iterator/lwg3390.cc b/libstdc++-v3/testsuite/24_iterators/move_iterator/lwg3390.cc new file mode 100644 index 00000000000..1df7caccece --- /dev/null +++ b/libstdc++-v3/testsuite/24_iterators/move_iterator/lwg3390.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +#include + +using __gnu_test::test_range; +using __gnu_test::input_iterator_wrapper; + +template +struct move_only_wrapper : input_iterator_wrapper +{ + using input_iterator_wrapper::input_iterator_wrapper; + + move_only_wrapper() + : input_iterator_wrapper(nullptr, nullptr) + { } + + move_only_wrapper(const move_only_wrapper&) = delete; + move_only_wrapper& + operator=(const move_only_wrapper&) = delete; + + move_only_wrapper(move_only_wrapper&&) = default; + move_only_wrapper& + operator=(move_only_wrapper&&) = default; + + using input_iterator_wrapper::operator++; + + move_only_wrapper& + operator++() + { + input_iterator_wrapper::operator++(); + return *this; + } +}; + +static_assert(std::input_iterator>); +static_assert(!std::forward_iterator>); +static_assert(!std::copyable>); + +// LWG 3390 +void +test01() +{ + int x[] = {1,2,3,4}; + test_range rx(x); + auto it = std::make_move_iterator(rx.begin()); +}