author | Leibo Wang <Leibo.Wang@Sun.COM> |
Wed, 11 Dec 2013 18:51:23 -0800 | |
changeset 1594 | 7302abf31ae0 |
parent 402 | 94ae4d75524c |
permissions | -rw-r--r-- |
402
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
1 |
--- stdcxx-4.2.1/tests/regress/21.string.append.stdcxx-438.cpp 2008-04-24 20:23:26.000000000 -0400 |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
2 |
+++ stdcxx-4.2.1/tests/regress/21.string.append.stdcxx-438.cpp 2011-01-28 01:18:03.733749580 -0500 |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
3 |
@@ -59,7 +59,11 @@ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
4 |
const char *p_; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
5 |
InputIterator (const char *p): p_ (p) { } |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
6 |
|
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
7 |
- char operator* () const { return *p_; } |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
8 |
+ // 24.1.1, t72: *a must be _convertible_ to T |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
9 |
+ // 24.1.1, p3: "Value type T is not required to be |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
10 |
+ // an Assignable type (23.1)." |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
11 |
+ // Also see 24.5.1.2, p1 |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
12 |
+ const char& operator* () const { return *p_; } |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
13 |
InputIterator& operator++ () { return ++p_, *this; } |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
14 |
InputIterator operator++ (int) { |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
15 |
return ++p_, InputIterator (p_ - 1); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
16 |
--- stdcxx-4.2.1/tests/strings/21.string.append.stdcxx-438.cpp 2011-01-06 23:30:16.580682374 -0500 |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
17 |
+++ stdcxx-4.2.1/tests/strings/21.string.append.stdcxx-438.cpp 2011-01-28 01:18:03.733749580 -0500 |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
18 |
@@ -0,0 +1,109 @@ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
19 |
+/************************************************************************ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
20 |
+* |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
21 |
+* 21.string.append.stdcxx-438.cpp - regression test for STDCXX-438 |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
22 |
+* |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
23 |
+* https://issues.apache.org/jira/browse/STDCXX-438 |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
24 |
+* |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
25 |
+* $Id: 21.string.append.stdcxx-438.cpp 641433 2008-03-26 17:39:28Z faridz $ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
26 |
+* |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
27 |
+*************************************************************************** |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
28 |
+* |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
29 |
+* Licensed to the Apache Software Foundation (ASF) under one or more |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
30 |
+* contributor license agreements. See the NOTICE file distributed |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
31 |
+* with this work for additional information regarding copyright |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
32 |
+* ownership. The ASF licenses this file to you under the Apache |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
33 |
+* License, Version 2.0 (the "License"); you may not use this file |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
34 |
+* except in compliance with the License. You may obtain a copy of |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
35 |
+* the License at |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
36 |
+* |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
37 |
+* http://www.apache.org/licenses/LICENSE-2.0 |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
38 |
+* |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
39 |
+* Unless required by applicable law or agreed to in writing, software |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
40 |
+* distributed under the License is distributed on an "AS IS" BASIS, |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
41 |
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
42 |
+* implied. See the License for the specific language governing |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
43 |
+* permissions and limitations under the License. |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
44 |
+* |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
45 |
+**************************************************************************/ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
46 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
47 |
+#include <cassert> |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
48 |
+#include <cstdlib> |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
49 |
+#include <cstring> |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
50 |
+#include <iterator> |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
51 |
+#include <new> |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
52 |
+#include <string> |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
53 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
54 |
+#ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
55 |
+ // disabled for compilers that can't reliably replace the operators |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
56 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
57 |
+void* operator new (std::size_t n) throw (std::bad_alloc) |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
58 |
+{ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
59 |
+ void* const ptr = std::malloc (n + sizeof n); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
60 |
+ std::memset (ptr, -1, n); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
61 |
+ *(std::size_t*)ptr = n; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
62 |
+ return (std::size_t*)ptr + 1; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
63 |
+} |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
64 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
65 |
+void operator delete (void *ptr) throw () |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
66 |
+{ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
67 |
+ if (ptr) { |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
68 |
+ std::memset (ptr, -1, *((std::size_t*)ptr - 1)); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
69 |
+ std::free ((std::size_t*)ptr - 1); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
70 |
+ } |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
71 |
+} |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
72 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
73 |
+#endif // _RWSTD_NO_REPLACEABLE_NEW_DELETE |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
74 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
75 |
+struct InputIterator: std::iterator<std::input_iterator_tag, char> |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
76 |
+{ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
77 |
+ const char *p_; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
78 |
+ InputIterator (const char *p): p_ (p) { } |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
79 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
80 |
+ // 24.1.1, t72: *a must be _convertible_ to T |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
81 |
+ // 24.1.1, p3: "Value type T is not required to be |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
82 |
+ // an Assignable type (23.1)." |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
83 |
+ // Also see 24.5.1.2, p1 |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
84 |
+ const char& operator* () const { return *p_; } |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
85 |
+ InputIterator& operator++ () { return ++p_, *this; } |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
86 |
+ InputIterator operator++ (int) { |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
87 |
+ return ++p_, InputIterator (p_ - 1); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
88 |
+ } |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
89 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
90 |
+ bool operator== (const InputIterator &rhs) const { return p_ == rhs.p_; } |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
91 |
+}; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
92 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
93 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
94 |
+int main () |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
95 |
+{ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
96 |
+ const char s[] = "abc"; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
97 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
98 |
+ { |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
99 |
+ std::string str (s); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
100 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
101 |
+ const char* p0 = s + 1; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
102 |
+ const char* p1 = p0 + 1; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
103 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
104 |
+ const InputIterator first (p0); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
105 |
+ const InputIterator last (p1); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
106 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
107 |
+ str.append (first, last); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
108 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
109 |
+ assert ("abcb" == str); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
110 |
+ } |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
111 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
112 |
+ { |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
113 |
+ std::string str (s); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
114 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
115 |
+ const char* p0 = str.data () + 1; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
116 |
+ const char* p1 = p0 + 1; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
117 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
118 |
+ const InputIterator first (p0); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
119 |
+ const InputIterator last (p1); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
120 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
121 |
+ str.append (first, last); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
122 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
123 |
+ assert ("abcb" == str); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
124 |
+ } |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
125 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
126 |
+ return 0; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
127 |
+} |