--- stdcxx-4.2.1/tests/regress/21.string.append.stdcxx-438.cpp 2008-04-24 20:23:26.000000000 -0400
+++ stdcxx-4.2.1/tests/regress/21.string.append.stdcxx-438.cpp 2011-01-28 01:18:03.733749580 -0500
@@ -59,7 +59,11 @@
const char *p_;
InputIterator (const char *p): p_ (p) { }
- char operator* () const { return *p_; }
+ // 24.1.1, t72: *a must be _convertible_ to T
+ // 24.1.1, p3: "Value type T is not required to be
+ // an Assignable type (23.1)."
+ // Also see 24.5.1.2, p1
+ const char& operator* () const { return *p_; }
InputIterator& operator++ () { return ++p_, *this; }
InputIterator operator++ (int) {
return ++p_, InputIterator (p_ - 1);
--- stdcxx-4.2.1/tests/strings/21.string.append.stdcxx-438.cpp 2011-01-06 23:30:16.580682374 -0500
+++ stdcxx-4.2.1/tests/strings/21.string.append.stdcxx-438.cpp 2011-01-28 01:18:03.733749580 -0500
@@ -0,0 +1,109 @@
+/************************************************************************
+*
+* 21.string.append.stdcxx-438.cpp - regression test for STDCXX-438
+*
+* https://issues.apache.org/jira/browse/STDCXX-438
+*
+* $Id: 21.string.append.stdcxx-438.cpp 641433 2008-03-26 17:39:28Z faridz $
+*
+***************************************************************************
+*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed
+* with this work for additional information regarding copyright
+* ownership. The ASF licenses this file to you under the Apache
+* License, Version 2.0 (the "License"); you may not use this file
+* except in compliance with the License. You may obtain a copy of
+* the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+* implied. See the License for the specific language governing
+* permissions and limitations under the License.
+*
+**************************************************************************/
+
+#include <cassert>
+#include <cstdlib>
+#include <cstring>
+#include <iterator>
+#include <new>
+#include <string>
+
+#ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
+ // disabled for compilers that can't reliably replace the operators
+
+void* operator new (std::size_t n) throw (std::bad_alloc)
+{
+ void* const ptr = std::malloc (n + sizeof n);
+ std::memset (ptr, -1, n);
+ *(std::size_t*)ptr = n;
+ return (std::size_t*)ptr + 1;
+}
+
+void operator delete (void *ptr) throw ()
+{
+ if (ptr) {
+ std::memset (ptr, -1, *((std::size_t*)ptr - 1));
+ std::free ((std::size_t*)ptr - 1);
+ }
+}
+
+#endif // _RWSTD_NO_REPLACEABLE_NEW_DELETE
+
+struct InputIterator: std::iterator<std::input_iterator_tag, char>
+{
+ const char *p_;
+ InputIterator (const char *p): p_ (p) { }
+
+ // 24.1.1, t72: *a must be _convertible_ to T
+ // 24.1.1, p3: "Value type T is not required to be
+ // an Assignable type (23.1)."
+ // Also see 24.5.1.2, p1
+ const char& operator* () const { return *p_; }
+ InputIterator& operator++ () { return ++p_, *this; }
+ InputIterator operator++ (int) {
+ return ++p_, InputIterator (p_ - 1);
+ }
+
+ bool operator== (const InputIterator &rhs) const { return p_ == rhs.p_; }
+};
+
+
+int main ()
+{
+ const char s[] = "abc";
+
+ {
+ std::string str (s);
+
+ const char* p0 = s + 1;
+ const char* p1 = p0 + 1;
+
+ const InputIterator first (p0);
+ const InputIterator last (p1);
+
+ str.append (first, last);
+
+ assert ("abcb" == str);
+ }
+
+ {
+ std::string str (s);
+
+ const char* p0 = str.data () + 1;
+ const char* p1 = p0 + 1;
+
+ const InputIterator first (p0);
+ const InputIterator last (p1);
+
+ str.append (first, last);
+
+ assert ("abcb" == str);
+ }
+
+ return 0;
+}