diff mbox

21_strings/basic_string/capacity/wchar_t/18654.cc

Message ID CAGWvnynw3zVbZw0hFWR_UqEt4bMmyTvfPua+mEPxnVRXiD1msw@mail.gmail.com
State New
Headers show

Commit Message

David Edelsohn Nov. 13, 2015, 6:40 p.m. UTC
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.

Thanks, David

Comments

David Edelsohn Nov. 13, 2015, 11:53 p.m. UTC | #1
On Fri, Nov 13, 2015 at 1:40 PM, David Edelsohn <dje.gcc@gmail.com> wrote:
> 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

Jonathan,

AIX has 2-byte wchar_t in 32 bit mode, which seems to be the cause of
all of the libstdc++ testsuite wchar_t failures.  If GCC libstdc++ is
suppose to shrink-to-fit, how should the testcases be fixed?

Thanks, David
Jonathan Wakely Nov. 14, 2015, 12:56 a.m. UTC | #2
On 13 November 2015 at 23:53, David Edelsohn <dje.gcc@gmail.com> wrote:
> On Fri, Nov 13, 2015 at 1:40 PM, David Edelsohn <dje.gcc@gmail.com> wrote:
>> 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
>
> Jonathan,
>
> AIX has 2-byte wchar_t in 32 bit mode, which seems to be the cause of
> all of the libstdc++ testsuite wchar_t failures.  If GCC libstdc++ is
> suppose to shrink-to-fit, how should the testcases be fixed?

It's shrink-to-fit, but not below a minimum size, which depends on
sizeof(wchar_t).

Something like https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=63f5425911daddb9a328565cb0acc3b0f30144fa#patch81
would work for both old and new string ABIs, I'll prepare an
equivalent patch for the wchar_t test case.
diff mbox

Patch

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 );
     }
 }