This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/23087] Misleading warning, "... differ in signedness"
- From: "kst at mib dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Mar 2008 21:49:28 -0000
- Subject: [Bug c/23087] Misleading warning, "... differ in signedness"
- References: <bug-23087-7039@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #10 from kst at mib dot org 2008-03-30 21:49 -------
(In reply to comment #9)
> >I'd expect the warning to be muted in one of the calls, depending on
> -f{un}signed-char.
>
> No, char is a seperate type from signed char and unsigned char so they are
> always incompatiable when it comes to pointers to them.
>
> Closing as invalid.
Yes, they're incompatible -- but that's not what the warning says.
I'm now using gcc 4.1.3. (Note that the warning doesn't appear without
"-pedantic".) Here's the current behavior:
========================================
% cat tmp.c
void foo(void)
{
signed char *ps = "signed?";
unsigned char *pu = "unsigned?";
}
% gcc --version
gcc (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
Copyright (C) 2006 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 -c -pedantic tmp.c
tmp.c: In function `foo':
tmp.c:3: warning: pointer targets in initialization differ in signedness
tmp.c:4: warning: pointer targets in initialization differ in signedness
========================================
On my system plain char is signed, so for the initialization of ps,
the pointer targets *don't* differ in signedness. A warning is
necessary; the warning that's currently printed is incorrect.
Here's what it should do:
========================================
[...]
% gcc -c -pedantic -c tmp.c
tmp.c: In function `foo':
tmp.c:3: warning: initialization from incompatible pointer type
tmp.c:4: warning: initialization from incompatible pointer type
========================================
--
kst at mib dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23087