From 8a7fb87eae6a9ba8ba0a715d92912893b218512c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Dumont?= Date: Wed, 15 Oct 2014 20:40:31 +0000 Subject: [PATCH] re PR libstdc++/63500 (bug in debug version of std::make_move_iterator?) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2014-10-15 François Dumont Jonathan Wakely PR libstdc++/63500 * include/debug/functions.h (__foreign_iterator_aux2): Do not check for foreign iterators if input iterators returns rvalue reference. * testsuite/23_containers/vector/63500.cc: New. Co-Authored-By: Jonathan Wakely From-SVN: r216286 --- libstdc++-v3/ChangeLog | 8 ++++ libstdc++-v3/include/debug/functions.h | 14 +++++-- .../testsuite/23_containers/vector/63500.cc | 39 +++++++++++++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 libstdc++-v3/testsuite/23_containers/vector/63500.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 711cd2374da..89b86eb1b20 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2014-10-15 François Dumont + Jonathan Wakely + + PR libstdc++/63500 + * include/debug/functions.h (__foreign_iterator_aux2): Do not check for + foreign iterators if input iterators returns rvalue reference. + * testsuite/23_containers/vector/63500.cc: New. + 2014-10-15 Paolo Carlini * testsuite/21_strings/basic_string/capacity/char/shrink_to_fit.cc: diff --git a/libstdc++-v3/include/debug/functions.h b/libstdc++-v3/include/debug/functions.h index b48c36d4a1e..0e7f1b7855c 100644 --- a/libstdc++-v3/include/debug/functions.h +++ b/libstdc++-v3/include/debug/functions.h @@ -34,7 +34,7 @@ // _Iter_base #include // for __is_integer #include // for __addressof and addressof -# include // for less +#include // for less #if __cplusplus >= 201103L # include // for is_lvalue_reference and __and_ #endif @@ -252,8 +252,16 @@ namespace __gnu_debug const _InputIterator& __other, const _InputIterator& __other_end) { - return __foreign_iterator_aux3(__it, __other, __other_end, - _Is_contiguous_sequence<_Sequence>()); +#if __cplusplus < 201103L + typedef _Is_contiguous_sequence<_Sequence> __tag; +#else + using __lvalref = std::is_lvalue_reference< + typename std::iterator_traits<_InputIterator>::reference>; + using __contiguous = _Is_contiguous_sequence<_Sequence>; + using __tag = typename std::conditional<__lvalref::value, __contiguous, + std::__false_type>::type; +#endif + return __foreign_iterator_aux3(__it, __other, __other_end, __tag()); } /* Handle the case where we aren't really inserting a range after all */ diff --git a/libstdc++-v3/testsuite/23_containers/vector/63500.cc b/libstdc++-v3/testsuite/23_containers/vector/63500.cc new file mode 100644 index 00000000000..99fc9f4007f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/63500.cc @@ -0,0 +1,39 @@ +// -*- C++ -*- + +// Copyright (C) 2014 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++11" } +// { dg-do compile } + +#include +#include +#include + +class Foo +{}; + +void +test01() +{ + __gnu_debug::vector> v; + __gnu_debug::vector> w; + + v.insert(end(v), + make_move_iterator(begin(w)), + make_move_iterator(end(w))); +} -- 2.30.2