This is the mail archive of the 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]
Other format: [Raw text]

Re: signed vs unsigned pointer warning

On Tue, 21 Sep 2004, Richard Henderson wrote:
> [ Forwarded from the thread beginning at
> ]

Btw, please do look at that first email, and in particular about "char".

The fact is, "char" is neither clearly signed nor unsigned, so it looks to
be clearly a bug to complain about assignment either way. Also, "char"  
ends up being special because there are magic language features that are
explicitly "char", but make sense for both signed and unsigned types,
notably constant strings (but also standard-defined string functions like
"strlen()" that are defined in terms of taking a "const char *").

In other words, I'd argue _strongly_ to allow at least "char *" to be
compatible with both "unsigned char *" and "signed char *". Anything else
is just madness.

Making "signed char *" be incompatible with "unsigned char *" (ie
_explicit_ signedness) sounds sane enough, but it may be that gcc can't
tell the difference internally.

Also, can we please add a flag to turn this off? I'd prefer to see
something like "-W[no-]typesign", which is what I already do in sparse (in
sparse it currently defaults to being off pending resolution of whether it
makes sense at all).

As to the argument that signed and unsigned types are incompatible - that
may be true in theory ("C language lawyers"), but it's certainly not true
in practice. I'd hope that practice matters.


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