From nobody@FreeBSD.ORG  Fri May 19 00:00:08 2000
Return-Path: <nobody@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
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@FreeBSD.org
Subject: std::basic_string<unsigned char>::c_str() doesn't compile
X-Send-Pr-Version: www-1.0

>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:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 19 00:10:01 PDT 2000
>Closed-Date:    Sat Jul 21 19:34:52 PDT 2001
>Last-Modified:  Sat Jul 21 19:36:15 PDT 2001
>Originator:     Gottfried Ganauge
>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:
State-Changed-From-To: open->feedback 
State-Changed-By: schweikh 
State-Changed-When: Sun Jun 17 04:44:07 PDT 2001 
State-Changed-Why:  
I can't reproduce this. Instead the script produces this on -current: 

schweikh@hal9000:~/tmp $ ./tst 
+ cat x.cc 
# include <string> 

typedef unsigned char BYTE; 
typedef basic_string<BYTE> bstring; 

const BYTE *get_cstbstring const &s) { returns.c_st)); } 
+ c++ -c x.cc 
x.cc:6: syntax error before `const' 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=18672 
State-Changed-From-To: feedback->open 
State-Changed-By: schweikh 
State-Changed-When: Sun Jun 17 04:54:39 PDT 2001 
State-Changed-Why:  
Whoops; pasto. I can reproduce it. Have you submitted this to the 
GNU folks? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=18672 

From: =?iso-8859-1?Q?Gottfried_Gan=DFauge?= <ganssauge@gmx.de>
To: <freebsd-gnats-submit@FreeBSD.org>, "Ich" <ganssauge@gmx.de>
Cc:  
Subject: Re: gnu/18672: std::basic_string<unsigned char>::c_str() doesn't compile
Date: Sun, 17 Jun 2001 23:26:12 +0200

 No I didn't.
 It was already being addressed in the new libstdc++-Project.
 The latest gcc-3.0 snapshot does not have a problem with that code (if you
 add "using namespace std;" at the proper place).
 My motivation at that time (it's only 13 months since then) was a fix within
 the frame of the FreeBSD project, because that
 was my primary development platform at that time and I'm still doing cvsup
 and build/install world on a regular basis.
 Don't get me wrong, I personally don't mind to install a patched version of
 that header myself on my own machine,
 but I absolutely hate it when I need to reinstall that patch every so often.
 So if it's not an option to make that fix within the FreeBSD copy of the
 GNU-Sources, please close the PR.
 
 Cheers,
 
 Gottfried
 
State-Changed-From-To: open->closed 
State-Changed-By: mike 
State-Changed-When: Sat Jul 21 19:34:52 PDT 2001 
State-Changed-Why:  

FreeBSD as a rule doesn't make modifications to vendor files. 
5.0-RELEASE will include GCC 3.0, so I guess you'll have to keep 
it locally patched until then. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=18672 
>Unformatted:
