[Bug c/23087] Misleading warning, "... differ in signedness"

2006-01-16 Thread axel at zankasoftware dot com


--- Comment #8 from axel at zankasoftware dot com  2006-01-16 17:14 ---
There's also the following issue, which seem related.

$ cat test.c
void nil_uch(unsigned char *uch) {
*uch = 0;
}

void nil_sch(signed char *sch) {
*sch = 0;
}

int main(void) {
char ch = 0;

nil_uch(&ch);
nil_sch(&ch);

return 0;
}

$ gcc --version
powerpc-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5250)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc -o test test.c
test.c: In function 'main':
test.c:14: warning: pointer targets in passing argument 1 of 'nil_uch' differ
in signedness
test.c:15: warning: pointer targets in passing argument 1 of 'nil_sch' differ
in signedness

I'd expect the warning to be muted in one of the calls, depending on
-f{un}signed-char.


-- 

axel at zankasoftware dot com changed:

   What|Removed |Added

     CC|        |axel at zankasoftware dot
       ||com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23087



[Bug c/19371] New: Missing uninitialized warning

2005-01-11 Thread axel at zankasoftware dot com
Consider the following code snippet:

$ cat testcase.c
int bar(int n) {
return n + 1;
}


int main(void) {
int a = bar(a);
int b, c, d;
b = bar(b);
(void) bar(c);
return bar(d);
}

Both a, b, c and d are used before they are initialized. However, we only get a 
warning from d in gcc 
3.3/3.4.

$ gcc -O2 -Wuninitialized testcase.c 
testcase.c: In function `main':
testcase.c:8: warning: `d' might be used uninitialized in this function

Tested on:
gcc version 3.3 20030304 (Apple Computer, Inc. build 1640)
gcc version 3.4.2 [FreeBSD] 20040728

In gcc 2.95, we get a warning from b, c and d, but not a.

$ gcc -O2 -Wuninitialized testcase.c
testcase.c: In function `main':
testcase.c:8: warning: `b' might be used uninitialized in this function
testcase.c:8: warning: `c' might be used uninitialized in this function
testcase.c:8: warning: `d' might be used uninitialized in this function

Tested on:
gcc version 2.95.3 20010125 (prerelease) (OpenBSD)

-- 
   Summary: Missing uninitialized warning
   Product: gcc
   Version: 3.4.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: axel at zankasoftware dot com
CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19371