This is the mail archive of the
mailing list for the GCC project.
Re: signed vs unsigned pointer warning
- From: Linus Torvalds <torvalds at osdl dot org>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 21 Sep 2004 11:48:36 -0700 (PDT)
- Subject: Re: signed vs unsigned pointer warning
- References: <20040921182618.GA31349@redhat.com>
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.