libstdc++/325

Neil Booth neil@daikokuya.demon.co.uk
Sun Apr 1 00:00:00 GMT 2001


The following reply was made to PR libstdc++/325; it has been noted by GNATS.

From: Neil Booth <neil@daikokuya.demon.co.uk>
To: Heiko.Scheit@mpi-hd.mpg.de
Cc: Phil Edwards <pedwards@disaster.jaj.com>, gcc-gnats@gcc.gnu.org,
	nobody@gcc.gnu.org
Subject: Re: libstdc++/325
Date: Wed, 31 Jan 2001 00:04:35 +0000

 Heiko.Scheit@mpi-hd.mpg.de wrote:-
 
 >   A C++ string (contrary to the common C (NUL-terminated) string)
 >   knows how long it is and there is no reason to treat any char(acter)
 >   in a special way.  Therefore I should be able to create a string
 >   like
 > 
 >       string test("\0\0\0\0\0");
 
 No, that is identical in every respect to
 
     string test ("");
 
 Remember that constructor is being passed common C strings (string
 literals, in fact).
 
 >   So, should the programmer take care and write
 >   '\0'+'\0'+'\0'+'\0'+'\0' or should the compiler take care.  Is it
 >   possible for the compiler to take care?
 
 You need to find another way to do what you want, yes.  I don't know
 libstdc++ well, but maybe a constructor takes a length parameter?
 
 >   By the way, when I run the test program that I submitted in the
 >   original bug report, string::find() does NOT return zero but
 >   string::size(), which is wrong in any case.
 > 
 > % ./a.out
 > test.size() =4
 > test.find("\0") =4
 
 I've not run your tests again, but all your tests should have the same
 result as using "" in place of "\0".  If they don't (which I highly
 doubt), that's a bug.
 
 If "" gives the wrong answer, that's a separate issue.
 
 As for your other questions, I'll have to defer to an expert like Phil
 <g>.
 
 Neil.


More information about the Gcc-prs mailing list