[RFC] First 3.5 project: don't assign _S_terminal in string::c_str()
Paolo Carlini
pcarlini@suse.de
Sun Jan 18 00:32:00 GMT 2004
Paolo Carlini wrote:
> By the way, due to 21.3.4 this is a *bug*, that we should fix in
> 3.4 (3.3?) too. Testcase:
This is more robust (fails when i ~ 500 on both i686 and
x86_64, mainline and branch):
#include <string>
#include <cassert>
int main()
{
for (int i = 0; i < 2000; ++i)
{
std::string a;
for (int j = 0; j < i; ++j)
a += 'a';
a.reserve(i + 10);
const std::string b(a);
assert( b[i] == '\0' );
}
}
Paolo.
More information about the Libstdc++
mailing list