This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


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

Bug report


Originator 
	David Sannier

Organization 

Confidential 
	no

Synopsis 
	basic_string<>::c_str() bug

Severity 
     non-critical 

Priority 
     low 

Category 
     libstdc++ 

Class 
     sw-bug 

Release 
     gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)

Environment 
	OS : Linux 
	Hardware architecture : i386 (PII)

Description 
/usr/include/g++-2/std/bastring.h: In method `const unsigned char *
basic_string<unsigned char,string_char_traits<unsigned
char>,__default_alloc_template<true,0> >::c_str<unsigned char,
string_char_traits<unsigned char>, alloc>() const':
essai15.cc:8:   instantiated from here
/usr/include/g++-2/std/bastring.h:301: warning: return to `const unsigned
char *' from `char *' changes signedness

How-To-Repeat 
#include <string>

typedef basic_string<unsigned char> Ustring;

int main(void)
{
  Ustring s = (unsigned char *)"toto\n";
  const unsigned char* c = s.c_str();

  return 0;
}

Fix 
Add the apropriate cast :

Replace

  const charT* c_str () const
    { if (length () == 0) return ""; terminate (); return data (); }

By

  const charT* c_str () const
    { if (length () == 0) return (const charT*)""; terminate (); return data
(); }



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