Given the following source:

1:   #include <stdio.h>

3:   unsigned char *p = NULL;
4:   char *s = NULL;

6:   unsigned char *p1 = "p";
7:   char *s1 = "s";

9:  int main()  {
10:    s = p;

12:    char c=255;
13:    printf("%d",c);

15:    return 0;
   }

   gcc -Wall _.c -o _ && ./_

produces:

   _.c:6: warning: pointer targets in initialization differ in signedness
   _.c: In function ‘main’:
   _.c:10: warning: pointer targets in assignment differ in signedness
   -1

   gcc -funsigned-char  -Wall _.c -o _ && ./_

produces:

   _.c:6: warning: pointer targets in initialization differ in signedness
   _.c: In function ‘main’:
   _.c:10: warning: pointer targets in assignment differ in signedness
   255

and, finally, 

   gcc  -funsigned-char  -Wno-pointer-sign -Wall _.c -o _ && ./_ /_

produces

   255

Reported issue: 
   gcc generates excessive signedness mismatch warning

Expected result:
   -funsigned-char must promote "char" to "unsigned char" and not issues the
warnings.

Known workaround:
   Use -Wno-pointer-sign. 

   However, this supporesses warnings for all types, which is rarely
acceptable. Note that the char signedness issue is typically a side effect of
Unicodization of the project from ASCII encodings to UTF-8.


-- 
           Summary: Non-functional -funsigned-char: signed/unsigned mismatch
                    is reported
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcc at brainhub dot org
 GCC build triplet: gcc version 4.1.0 20060304 (Red Hat 4.1.0-3) [standard
                    FC 5]
  GCC host triplet: i386-redhat-linux
GCC target triplet: Linux 2.6.16.20 #1 PREEMPT Fri Jun 9 23:10:34 PDT 2006
                    i686 i686


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

Reply via email to