diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index fcc77fca12fa47cf2ef51053cefb66da4825336b..157695246384d8eb7a38d4eafcb7af6c98dbc123 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,16 @@
+2005-12-24  Paolo Carlini  <pcarlini@suse.de>
+
+	* include/bits/stl_algobase.h (fill(const _Deque_iterator&,
+	const _Deque_iterator&, const _Tp&)): Deal, correctly, only
+	with iterators (leave const_iterators alone).
+
+2005-12-24  Paolo Carlini  <pcarlini@suse.de>
+
+	* include/bits/stl_algobase.h (fill(const _Deque_iterator<>&,
+	const _Deque_iterator<>&, const _Tp&)): Add.
+
+	* testsuite/23_containers/deque/cons/assign/1.cc: New.
+
 2005-12-19  Paolo Carlini  <pcarlini@suse.de>
 
 	* include/bits/stl_deque.h (deque<>::resize, _M_fill_assign):
diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h
index 730699648e1802f38a9fda549e18d818d5ad3013..9a2e7af16c40b1c1ea31780598dd30d4cda1a3e2 100644
--- a/libstdc++-v3/include/bits/stl_algobase.h
+++ b/libstdc++-v3/include/bits/stl_algobase.h
@@ -594,6 +594,32 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     std::memset(__first, static_cast<unsigned char>(__tmp), __last - __first);
   }
 
+  template<typename _Tp, typename _Ref, typename _Ptr>
+    struct _Deque_iterator;
+
+  // Overload for deque::iterators, exploiting the "segmented-iterator
+  // optimization".  NB: leave const_iterators alone!
+  template<typename _Tp>
+    void
+    fill(const _Deque_iterator<_Tp, _Tp&, _Tp*>& __first,
+	 const _Deque_iterator<_Tp, _Tp&, _Tp*>& __last, const _Tp& __value)
+    {
+      typedef typename _Deque_iterator<_Tp, _Tp&, _Tp*>::_Self _Self;
+
+      for (typename _Self::_Map_pointer __node = __first._M_node + 1;
+           __node < __last._M_node; ++__node)
+	std::fill(*__node, *__node + _Self::_S_buffer_size(), __value);
+
+      if (__first._M_node != __last._M_node)
+	{
+	  std::fill(__first._M_cur, __first._M_last, __value);
+	  std::fill(__last._M_first, __last._M_cur, __value);
+	}
+      else
+	std::fill(__first._M_cur, __last._M_cur, __value);
+    }
+
+
   template<bool>
     struct __fill_n
     {
diff --git a/libstdc++-v3/testsuite/23_containers/deque/cons/assign/1.cc b/libstdc++-v3/testsuite/23_containers/deque/cons/assign/1.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6b8a92c15432c4132e795236a7778c1a24044ff4
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/deque/cons/assign/1.cc
@@ -0,0 +1,51 @@
+// 2005-12-12  Paolo Carlini  <pcarlini@suse.de>
+//
+// Copyright (C) 2005 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.
+
+// 23.2.1.1 deque constructors, copy, and assignment
+
+#include <deque>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+  using namespace std;
+
+  int data3[10000];
+  fill(data3, data3 + 10000, 3);
+
+  int data5[10000];
+  fill(data5, data5 + 10000, 5);
+
+  for (deque<int>::size_type i = 0; i < 10000; ++i)
+    {
+      deque<int> d(rand() % 5000, 1);
+      d.assign(i, i % 2 ? 3 : 5);
+
+      VERIFY( d.size() == i );
+      VERIFY( equal(d.begin(), d.end(), i % 2 ? data3 : data5) );
+    }
+}
+
+int main()
+{
+  test01();
+  return 0;
+}