This is the mail archive of the libstdc++-prs@sources.redhat.com mailing list for the libstdc++ project.


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

libstdc++/95: bastring.h's c_str implementation prohibits charT's other than char



>Number:         95
>Category:       libstdc++
>Synopsis:       bastring.h's c_str implementation prohibits charT's other than char
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 06 11:27:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     ben@valinux.com
>Release:        2.95.2-13
>Organization:
>Environment:
debian potato
>Description:
The problem is that when you define use a template parameter for "charT"
for bastring as anything different than "char" the type that you pass in as the
template parameter doesn't match "" which is always of type "char*" when
g++ compiles the bastring.h header file.



>How-To-Repeat:
Try something like this:

#include <string>

int main()
  basic_string<unsigned char> foo;
  foo.c_str();
}
>Fix:
--- /usr/include/g++-3/std/bastring.h	Fri Jul  7 02:10:00 2000
+++ bastring.h	Fri Oct  6 10:55:14 2000
@@ -332,7 +332,7 @@
 
 public:
   const charT* c_str () const
-    { const charT* null_str = ""; 
+    { static const charT null_str[1]={0}; 
       if (length () == 0) return null_str; terminate (); return data (); }
   void resize (size_type n, charT c);
   void resize (size_type n)
>Release-Note:
>Audit-Trail:
>Unformatted:

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