[PATCH] D56997: Fix implementation of P0966 - string::reserve Should Not Shrink

Andrew Luo andrewluotechnologies at outlook.com
Sun Jan 20 18:08:12 PST 2019


Just FYI:

This is the test I used to determine that the implementation appears to be broken:

#include <iostream>
#include <string>

int main()
{
	::std::string s;
	s.reserve(100u);
	::std::cout << s.capacity() << ::std::endl;
	s.reserve(1u);
	::std::cout << s.capacity() << ::std::endl;
}

In a working implementation, this should print two equal numbers (for example, 111 and 111).  But using the latest development version of clang, it prints two different numbers (111 and 22 if I remember correctly).

Thanks,

-Andrew

-----Original Message-----
From: Andrew Luo via Phabricator <reviews at reviews.llvm.org> 
Sent: Sunday, January 20, 2019 6:02 PM
To: andrewluotechnologies at outlook.com; mclow.lists at gmail.com; eric at efcs.ca; ldionne at apple.com
Cc: libcxx-commits at lists.llvm.org; francisvm at yahoo.com
Subject: [PATCH] D56997: Fix implementation of P0966 - string::reserve Should Not Shrink

andrewluo created this revision.
andrewluo added reviewers: mclow.lists, EricWF, ldionne.

Repository:
  rCXX libc++

https://reviews.llvm.org/D56997

Files:
  include/string
  test/std/strings/basic.string/string.capacity/reserve.pass.cpp



More information about the libcxx-commits mailing list