MI failures related to string printing

Bob Rossi bob_rossi@cox.net
Fri Jan 12 12:30:00 GMT 2007


On Fri, Jan 12, 2007 at 12:18:44PM +0100, Mark Kettenis wrote:
> I think the whole idea of doing string comparisons for C (or C++)
> "char *" pointers is flawed.  There is no guarantee that a "char *"
> actually points to a null-terminated as the test shows.  You should
> not treat "char *" any different from other pointers like "int *", at
> least not by default.  You could implement a way for the user to
> specify that a "char *" is actually a pointer to a string instead of a
> single character.  But otherwise I think the string comparison should
> only do for languages that have a genuine string type, such as Pascal.

GDB handles char*'s specially in the print command. There is an option
to tell it that the string shouldn't be displayed as null-terminated.

I think it's appropriate to handle the char* special as long as there is
an option not to do so.

Bob Rossi



More information about the Gdb mailing list