[lkml]   [2007]   [Feb]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: somebody dropped a (warning) bomb
Linus Torvalds <> writes:
> On Fri, 9 Feb 2007, Sergei Organov wrote:
>> As far as I can read the C99 standard, the "char", "signed char", and
>> "unsigned char", are all different types:
> Indeed. Search for "pseudo-unsigned", and you'll see more. There are
> actually cases where "char" can act differently from _both_ "unsigned
> char" and "signed char".
>> If so, then the code above is broken no matter what representation of
>> "char" is chosen for given arch, as strcmp() takes "char*" arguments,
>> that are not compatible with either "signed char*" or "unsigned char*".
> ..and my argument is that a warning which doesn't allow you to call
> "strlen()" on a "unsigned char" array without triggering is a bogus
> warning, and must be removed.

Why strlen() should be allowed to be called with an incompatible pointer
type? My point is that gcc should issue *different warning*, -- the same
warning it issues here:

$ cat incompat.c
void foo(int *p);
void boo(long *p) { foo(p); }
$ gcc -W -Wall -c incompat.c
incompat.c:2: warning: passing argument 1 of 'foo' from incompatible pointer type

Calling strlen(char*) with "unsigned char*" argument does pass argument
of incompatible pointer type due to the fact that in C "char" and
"unsigned char" are two incompatible types, and it has nothing to do
with signedness.


-- Sergei.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2007-02-12 12:15    [W:0.113 / U:0.756 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site