re PR libstdc++/8466 (basic_stringbuf::str(basic_string const&) modifies its argument)

2002-11-05  Paolo Carlini  <pcarlini@unitus.it>

	PR libstdc++/8466
	* include/std/std_sstream.h
	(basic_stringbuf::str(const __string_type&)):
	Cannot use simple assignment since the COW-nature of v3
	basic_string is not taken into account in basic_stringbuf.
	* testsuite/27_io/stringstream_members.cc: Add test04 from PR.

From-SVN: r58838
This commit is contained in:
Paolo Carlini 2002-11-06 00:28:15 +01:00 committed by Paolo Carlini
parent e9577224cc
commit 81646a3157
3 changed files with 27 additions and 1 deletions

View File

@ -1,3 +1,12 @@
2002-11-05 Paolo Carlini <pcarlini@unitus.it>
PR libstdc++/8466
* include/std/std_sstream.h
(basic_stringbuf::str(const __string_type&)):
Cannot use simple assignment since the COW-nature of v3
basic_string is not taken into account in basic_stringbuf.
* testsuite/27_io/stringstream_members.cc: Add test04 from PR.
2002-11-05 John David Anglin <dave@hiauly1.hia.nrc.ca>
* configure.target (hppa*): Define cpu_include_dir.

View File

@ -105,7 +105,8 @@ namespace std
void
str(const __string_type& __s)
{
_M_string = __s;
// Cannot use _M_string = __s, since v3 strings are COW.
_M_string.assign(__s.c_str(), __s.size());
_M_stringbuf_init(_M_mode);
}

View File

@ -177,10 +177,26 @@ test03()
std::stringstream ss2(str3, std::ios_base::in|std::ios_base::out);
}
// libstdc++/8466
void test04()
{
bool test = true;
const char* strlit00 = "orvieto";
const std::string str00 = strlit00;
std::ostringstream oss;
oss.str(str00);
oss << "cortona";
VERIFY( str00 == strlit00 );
}
int main()
{
test01();
test02();
test03();
test04();
return 0;
}