New warning in gcc-4.0
I just upgraded to gcc-4.0 and found that it generates a new warning:
I wasn't even aware that doing that was a bad thing. Is it covered anywhere in the C standard? It also throws a fit if you do something like:
itsme@itsme:~/C$ cat signed.c
void func(unsigned char *str)
char str = "hi";
itsme@itsme:~/C$ gcc -Wall signed.c
signed.c: In function 'main':
signed.c:9: warning: pointer targets in passing argument 1 of 'func' differ in signedness
This is causing a whole lot of warnings to show up in all sorts of code that used to compile cleanly for me. I don't think this was a documented change either. Does anyone have any information on this that I might have missed? It just seems really annoying to me. You can't even disable the warning. You don't need to compile with -Wall for the warning to be generated.
itsme@itsme:~/C$ cat signed2.c
unsigned int *ptr;
int i = 5;
ptr = &i;
itsme@itsme:~/C$ gcc -Wall signed2.c -o signed2
signed2.c: In function 'main':
signed2.c:6: warning: pointer targets in assignment differ in signedness
char (by itself) is either unsigned or signed, but that in itself is implementation-specific.
Let the type `char' be unsigned, like `unsigned char'.
Each kind of machine has a default for what `char' should be. It
is either like `unsigned char' by default or like `signed char' by
Try with the above flag (there's also -fsigned-char) to make it clear what sign your unadorned char type is.