http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52938
--- Comment #2 from Abdul Tohmaz <abdul.tohmaz at emc dot com> 2012-04-11 20:32:26 UTC --- (In reply to comment #1) > Why do you think this is a bug? I don't see why x="aaa"; would not change the > reserve. > > The main reason why it changes the reserve is that the backing part is shared > between x and y. I have called: x.reserve(20); which I expect that 20 bytes (at least) to be reserved to this string. So I would expect no memory reallocation as long as my string can fit in my reserved request. Then I called x="aaa"; and then x += "bbb"; Why do I see memory is being reallocated even though the string x content can fit within what I requested in my reserve call?