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

            Bug ID: 60083
           Summary: Duplicate conversion warnings from negative integer to
                    unsigned type (gcc-4.3 emits only one warning)
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chengniansun at gmail dot com

I have the following code, and gcc-trunk emits duplicate warnings on the
implicit conversion from negative long long to unsigned short. 

Moreover, if I turn on -O1, gcc emits only one warning, but the message changes
to "large integer implicitly truncated to unsigned type".

Lastly, gcc-4.3 only emits one warning for this conversion. 


$: cat s.c
int *const a = 0;
unsigned fn1() {
  unsigned short s = ~0x4578ADBCAA1DE677LL ^ a == 0;
  return s;
}
$: gcc-trunk -c -Wconversion s.c
s.c: In function ‘fn1’:
s.c:3:22: warning: negative integer implicitly converted to unsigned type
[-Wsign-conversion]
   unsigned short s = ~0x4578ADBCAA1DE677LL ^ a == 0;
                      ^
s.c:3:22: warning: negative integer implicitly converted to unsigned type
[-Wsign-conversion]
$: gcc-trunk -c -O1 -Wconversion s.c
s.c: In function ‘fn1’:
s.c:3:22: warning: large integer implicitly truncated to unsigned type
[-Woverflow]
   unsigned short s = ~0x4578ADBCAA1DE677LL ^ a == 0;
                      ^
$: gcc-4.3 -c -O1 -Wconversion s.c
s.c: In function ‘fn1’:
s.c:3: warning: large integer implicitly truncated to unsigned type
$:

Reply via email to