From owner-freebsd-bugs Fri May 19 0:10:12 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 52ADF37BD58 for ; Fri, 19 May 2000 00:10:09 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id AAA43823; Fri, 19 May 2000 00:10:09 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: by hub.freebsd.org (Postfix, from userid 32767) id 03CFB37B53E; Fri, 19 May 2000 00:00:08 -0700 (PDT) Message-Id: <20000519070008.03CFB37B53E@hub.freebsd.org> Date: Fri, 19 May 2000 00:00:08 -0700 (PDT) From: ganssauge@gmx.de To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: gnu/18672: std::basic_string::c_str() doesn't compile Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 18672 >Category: gnu >Synopsis: std::basic_string::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::c_str() doesn't compile >How-To-Repeat: Consider the following Shell-script: #!/bin/sh cat >x.cc <<__EOF__ # include typedef unsigned char BYTE; typedef basic_string 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 typedef unsigned char BYTE; typedef basic_string 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,__default_alloc_template >::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