This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] 21_strings/basic_string/capacity/wchar_t/18654.cc
- From: David Edelsohn <dje dot gcc at gmail dot com>
- To: Jonathan Wakely <jwakely dot gcc at gmail dot com>, Paolo Carlini <paolo dot carlini at oracle dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 13 Nov 2015 13:40:51 -0500
- Subject: [PATCH] 21_strings/basic_string/capacity/wchar_t/18654.cc
- Authentication-results: sourceware.org; auth=none
http://www.cplusplus.com/reference/string/basic_string/reserve/
"Note that the resulting string capacity may be equal or greater than n."
The current testcase verifies that the capacity is exactly equal to
the length of the string or reserve value, but the standard allows the
capacity to be larger. On AIX, the capacity is larger and the
testcase incorrectly fails.
Linux x86-64:
i: 4
str.length: 4
str.capacity: 4
str.capacity: 12
str.capacity: 8
str.capacity: 4
AIX:
i: 4
str.length: 4
str.capacity: 7 <-- i
str.capacity: 14 <-- i*3
str.capacity: 8 <-- i*2
str.capacity: 7 <-- default
* 21_strings/basic_string/capacity/wchar_t/18654.cc: Verify the
capacity is greater than or equal to the requested amount.
Index: 18654.cc
===================================================================
--- 18654.cc (revision 230322)
+++ 18654.cc (working copy)
@@ -50,10 +50,10 @@
str.reserve(3 * i);
str.reserve(2 * i);
- VERIFY( str.capacity() == 2 * i );
+ VERIFY( str.capacity() >= 2 * i );
str.reserve();
- VERIFY( str.capacity() == i );
+ VERIFY( str.capacity() >= i );
}
}
Thanks, David