public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [v3] libstdc++/8466
@ 2002-11-05 15:39 Paolo Carlini
  0 siblings, 0 replies; only message in thread
From: Paolo Carlini @ 2002-11-05 15:39 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 441 bytes --]

Hi,

tested x86-linux, approved by Benjamin.

Ciao, Paolo.

////////////

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.

[-- Attachment #2: patch_8466 --]
[-- Type: text/plain, Size: 1234 bytes --]

diff -urN libstdc++-v3-orig/include/std/std_sstream.h libstdc++-v3/include/std/std_sstream.h
--- libstdc++-v3-orig/include/std/std_sstream.h	2002-03-06 22:22:55.000000000 +0100
+++ libstdc++-v3/include/std/std_sstream.h	2002-11-05 23:05:44.000000000 +0100
@@ -105,7 +105,8 @@
       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);
       }
 
diff -urN libstdc++-v3-orig/testsuite/27_io/stringstream_members.cc libstdc++-v3/testsuite/27_io/stringstream_members.cc
--- libstdc++-v3-orig/testsuite/27_io/stringstream_members.cc	2002-07-26 03:49:36.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/stringstream_members.cc	2002-11-05 22:57:05.000000000 +0100
@@ -177,10 +177,26 @@
   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;
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-11-05 23:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-05 15:39 [v3] libstdc++/8466 Paolo Carlini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).