------- Additional Comments From pogonyshev at gmx dot net 2005-08-20 18:48 ------- Because it defeats the effect of reserve() call on `s1'. I'm not saying I know how to avoid it, but I wonder if there is some strict policy behind `std::basic_string' reallocation behavior in GNU STL. Maybe this example shows that the policy is not implemented properly.
I think this example shows a perfectly common usage of strings where you reserve space for all the things you are going to stuff in the string and then make a copy of an intermediate results. With current GNU STL behavior, this doesn't work as expected, though, of course, it *will* give the correct result, it is only about optimizations. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23494