This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Signed/unsigned character arrays are not strings


> Date: Tue, 27 Feb 2007 16:53:16 -0500
> From: Daniel Jacobowitz <drow@false.org>
> 
> On Tue, Feb 27, 2007 at 11:06:17PM +0200, Eli Zaretskii wrote:
> > Doesn't a similar situation exist with "unsigned int" and "int", or
> > with "unsigned long" and "long"?  And yet we don't treat them
> > differently.
> > 
> > IOW, I think it's quite expected that explicit signedness is
> > relatively rare, since in the vast majority of cases it is simply not
> > needed.  Interpreting this phenomenon as saying something about what
> > kind of data is stored is not necessarily a good idea.
> 
> I feel that this is different for two reasons.  One is that the
> situation for int and long is not the same, because "int" and "signed
> int" are the same type in C - but "char" and "signed char" are not.
> Char is explicitly of indeterminate sign.  The other is that there is
> a widespread use of "char" for string data and "signed char" or
> "unsigned char" for non-string data.

Well, "char" really is "signed char" on most machines and "unsigned
char" on others.  One way to prevent the sign-extension problems this
sometimes causes, is to explicitly use "unsigned char *" for strings.

Anyway, I'm in favour of restore the traditional gdb behaviour of
printing all three as strings.

Mark


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