OSDN Git Service

2008-03-29 Paolo Carlini <pcarlini@suse.de>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 29 Mar 2008 22:38:19 +0000 (22:38 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 29 Mar 2008 22:38:19 +0000 (22:38 +0000)
PR libstdc++/35725
* include/bits/stl_algobase.h (__fill_a(_ForwardIterator,
_ForwardIterator, _Tp), __fill_a(_Tp*, _Tp*, _Tp),
__fill_n_a(_OutputIterator, _Size, _Tp), __fill_n_a(_Tp*, _Size,
_Tp)): Fix signatures.
* testsuite/25_algorithms/fill/35725.cc: New.
* testsuite/25_algorithms/fill_n/35725.cc: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@133721 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_algobase.h
libstdc++-v3/testsuite/25_algorithms/fill/35725.cc [new file with mode: 0644]
libstdc++-v3/testsuite/25_algorithms/fill_n/35725.cc [new file with mode: 0644]

index 13e3a26..f590074 100644 (file)
@@ -1,3 +1,13 @@
+2008-03-29  Paolo Carlini  <pcarlini@suse.de>
+
+       PR libstdc++/35725
+       * include/bits/stl_algobase.h (__fill_a(_ForwardIterator,
+       _ForwardIterator, _Tp), __fill_a(_Tp*, _Tp*, _Tp),
+       __fill_n_a(_OutputIterator, _Size, _Tp), __fill_n_a(_Tp*, _Size,
+       _Tp)): Fix signatures.
+       * testsuite/25_algorithms/fill/35725.cc: New.
+       * testsuite/25_algorithms/fill_n/35725.cc: Likewise.
+
 2008-03-29  Matthias Klose  <doko@ubuntu.com>
 
        * config/abi/post/s390-linux-gnu/baseline_symbols.txt: Update.
index 8f19453..9c64ef1 100644 (file)
@@ -1,6 +1,6 @@
 // Core algorithmic facilities -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -689,19 +689,24 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
   template<typename _ForwardIterator, typename _Tp>
     inline typename
     __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type
-    __fill_a(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
+    __fill_a(_ForwardIterator __first, _ForwardIterator __last,
+            const _Tp& __value)
     {
+      const _Tp __tmp = __value;
       for (; __first != __last; ++__first)
-       *__first = __value;
+       *__first = __tmp;
     }
 
   // Specialization: for char types we can use memset.
   template<typename _Tp>
     inline typename
     __gnu_cxx::__enable_if<__is_byte<_Tp>::__value, void>::__type
-    __fill_a(_Tp* __first, _Tp* __last, _Tp __c)
-    { __builtin_memset(__first, static_cast<unsigned char>(__c),
-                      __last - __first); }
+    __fill_a(_Tp* __first, _Tp* __last, const _Tp& __c)
+    {
+      const _Tp __tmp = __c;
+      __builtin_memset(__first, static_cast<unsigned char>(__tmp),
+                      __last - __first);
+    }
 
   /**
    *  @brief Fills the range [first,last) with copies of value.
@@ -740,17 +745,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
   template<typename _OutputIterator, typename _Size, typename _Tp>
     inline typename
     __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, _OutputIterator>::__type
-    __fill_n_a(_OutputIterator __first, _Size __n, _Tp __value)
+    __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value)
     {
+      const _Tp __tmp = __value;
       for (; __n > 0; --__n, ++__first)
-       *__first = __value;
+       *__first = __tmp;
       return __first;
     }
 
   template<typename _Size, typename _Tp>
     inline typename
     __gnu_cxx::__enable_if<__is_byte<_Tp>::__value, _Tp*>::__type
-    __fill_n_a(_Tp* __first, _Size __n, _Tp __c)
+    __fill_n_a(_Tp* __first, _Size __n, const _Tp& __c)
     {
       std::__fill_a(__first, __first + __n, __c);
       return __first + __n;
diff --git a/libstdc++-v3/testsuite/25_algorithms/fill/35725.cc b/libstdc++-v3/testsuite/25_algorithms/fill/35725.cc
new file mode 100644 (file)
index 0000000..0c5b0e4
--- /dev/null
@@ -0,0 +1,30 @@
+// { dg-do compile }
+
+// Copyright (C) 2008 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 2, 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 COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <string>
+#include <vector>
+#include <algorithm>
+
+// libstdc++/35725
+void test01()
+{
+  std::vector<std::string> foo(20);  
+  std::fill(foo.begin(), foo.end(), "bar");
+}
diff --git a/libstdc++-v3/testsuite/25_algorithms/fill_n/35725.cc b/libstdc++-v3/testsuite/25_algorithms/fill_n/35725.cc
new file mode 100644 (file)
index 0000000..a914d1c
--- /dev/null
@@ -0,0 +1,30 @@
+// { dg-do compile }
+
+// Copyright (C) 2008 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 2, 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 COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <string>
+#include <vector>
+#include <algorithm>
+
+// libstdc++/35725
+void test01()
+{
+  std::vector<std::string> foo(20);  
+  std::fill_n(foo.begin(), 20, "bar");
+}