Date: Fri, 19 May 2000 00:00:08 -0700 (PDT) From: ganssauge@gmx.de To: freebsd-gnats-submit@FreeBSD.org Subject: gnu/18672: std::basic_string<unsigned char>::c_str() doesn't compile Message-ID: <20000519070008.03CFB37B53E@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 18672
>Category: gnu
>Synopsis: std::basic_string<unsigned char>::c_str() doesn't compile
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Fri May 19 00:10:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Gottfried Ganßauge
>Release: FreeBSD 4.0-STABLE i386
>Organization:
private
>Environment:
FreeBSD borstel2.gorki120.de 4.0-STABLE FreeBSD 4.0-STABLE #2: Sat Apr 1 20:15:14 CEST 2000 Root@borstel2.gorki120.de:/sd0/src/sys/compile/borstel2 i386
>Description:
std::basic_string<unsigned char>::c_str() doesn't compile
>How-To-Repeat:
Consider the following Shell-script:
#!/bin/sh
cat >x.cc <<__EOF__
# include <string>
typedef unsigned char BYTE;
typedef basic_string<BYTE> bstring;
const BYTE *get_cstr(bstring const &s) { return (s.c_str()); }
__EOF__
set -x
cat x.cc
c++ -c x.cc
if you run that script, you get the following output:
+ cat x.cc
# include <string>
typedef unsigned char BYTE;
typedef basic_string<BYTE> bstring;
const BYTE *get_cstr(bstring const &s) { return (s.c_str()); }
+ c++ -c x.cc
/usr/include/g++/std/bastring.h: In method `const BYTE * basic_string<unsigned char,string_char_traits<unsigned char>,__default_alloc_template<false,0> >::c_str() const':
x.cc:6: instantiated from here
/usr/include/g++/std/bastring.h:338: return to `const BYTE *' from `const char *' changes signedness
>Fix:
Use the following patch:
--- /usr/include/g++/std/bastring.h Mon Apr 24 22:51:45 2000
+++ bastring.h Mon Apr 24 23:01:37 2000
@@ -335,7 +335,7 @@
public:
const charT* c_str () const
- { if (length () == 0) return ""; terminate (); return data (); }
+ { if (length () == 0) return (charT const *) ""; terminate (); return data (); }
void resize (size_type n, charT c);
void resize (size_type n)
{ resize (n, eos ()); }
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000519070008.03CFB37B53E>
