This is the mail archive of the
libstdc++-prs@sourceware.cygnus.com
mailing list for the libstdc++ project.
Re: libstdc++/52: can't call c_str() from a basic_string<unsigned char> (fwd)
- To: nobody at sourceware dot cygnus dot com
- Subject: Re: libstdc++/52: can't call c_str() from a basic_string<unsigned char> (fwd)
- From: Benjamin Kosnik <bkoz at cygnus dot com>
- Date: 31 Mar 2000 19:47:01 -0000
- Cc: libstdc++-prs at sourceware dot cygnus dot com,
- Reply-To: Benjamin Kosnik <bkoz at cygnus dot com>
The following reply was made to PR libstdc++/52; it has been noted by GNATS.
From: Benjamin Kosnik <bkoz@cygnus.com>
To: libstdc++-gnats@sourceware.cygnus.com
Cc:
Subject: Re: libstdc++/52: can't call c_str() from a basic_string<unsigned char> (fwd)
Date: Fri, 31 Mar 2000 11:39:43 -0800 (PST)
---------- Forwarded message ----------
Date: Thu, 30 Mar 2000 14:35:27 -0800
From: ncm@zembu.com
To: bkoz@cygnus.com
Subject: Re: libstdc++/52: can't call c_str() from a basic_string<unsigned char>
> >Number: 52
> >Category: libstdc++
> >Synopsis: can't call c_str() from a basic_string<unsigned char>
> >Confidential: no
> >Severity: serious
> >Priority: medium
> >Responsible: unassigned
> >State: open
> >Class: sw-bug
> >Submitter-Id: net
> >Arrival-Date: Thu Mar 30 12:27:00 PST 2000
> >Closed-Date:
> >Last-Modified:
> >Originator: debian frozen
> >Release: ibstdc++2.10-dev 2.95.2-8
> >Organization:
> >Environment:
> debian frozen
> >Description:
> The problem is that "" is a signed char * and so when it is
> assigned to charT* there is no problem as long as charT*
> is a signed char. The problem is if instantiate a basic
> string with an unsigned char rather than a char this doesn't
> work. I don't know how this will behave with multibyte
> characters.
> >How-To-Repeat:
>
> >Fix:
> RCS file: RCS/bastring.h,v
> retrieving revision 1.1
> diff -u -r1.1 bastring.h
> --- bastring.h 2000/03/30 00:44:05 1.1
> +++ bastring.h 2000/03/30 00:46:05
> @@ -335,7 +335,7 @@
>
> public:
> const charT* c_str () const
> - { const charT* null_str = "";
> + { const charT* null_str = reinterpret_cast<const charT*>("");
> if (length () == 0) return null_str; terminate (); return data (); }
> void resize (size_type n, charT c);
> void resize (size_type n)
I don't agree with this change. A better fix would be:
> + { static const charT null_str[] = { charT() };
Of course, since this is the old, dead libstdc++, I don't care what
happens there.
Nathan
ncm