libstdc++/5182: basic_string::replace may produce incorrect results if part of

anonymous@sources.redhat.com anonymous@sources.redhat.com
Mon Dec 24 01:18:00 GMT 2001


>Number:         5182
>Category:       libstdc++
>Synopsis:       basic_string::replace may produce incorrect results if part of
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Dec 23 16:26:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Simon Saunders
>Release:        3.0.3
>Organization:
>Environment:
Red Hat Linux 6.2
>Description:
Calling s.replace(pos, num_chars, s) for a string s may not work
properly if the string already has sufficient capacity for the result.
>How-To-Repeat:
The following test program prints "ABABAB". The correct output is
"ABABCD".

#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s("ABCD");
	s.reserve(10);
	s.replace(2, 2, s);
	cout << s << endl;
	return 0;
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
 a string is replaced by itself.
 From: simon.saunders@net.ntl.com
 Reply-To: simon.saunders@net.ntl.com
 X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31)
 X-GNATS-Notify: 
 
 a string is replaced by itself.



More information about the Gcc-bugs mailing list