This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[libstdc++] Patch for basic_string<>::c_str()


The current implementation of basic_string<>::c_str() does not follow
the standard and will fail for character-types other than char.

The appended patch solves this problem.

--- std/bastring.h	Fri Mar 24 11:57:33 2000
+++ std/bastring.h.orig	Fri Mar 24 02:08:09 2000
@@ -332,8 +332,7 @@
 
 public:
   const charT* c_str () const
-    { static charT const	empty_str=eos();
-      if (length () == 0) return &empty_str; terminate (); return data (); }
+    { if (length () == 0) return ""; terminate (); return data (); }
   void resize (size_type n, charT c);
   void resize (size_type n)
     { resize (n, eos ()); }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]