[Bug c/60083] Duplicate conversion warnings from negative integer to unsigned type (gcc-4.3 emits only one warning)

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri May 19 15:20:00 GMT 2017


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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
It's useful to compare GCC output to Clang's (with no options):

t.c:3:44: warning: ^ has lower precedence than ==; == will be evaluated first
      [-Wparentheses]
  unsigned short s = ~0x4578ADBCAA1DE677LL ^ a == 0;
                                           ^~~~~~~~
t.c:3:44: note: place parentheses around the '==' expression to silence this
      warning
  unsigned short s = ~0x4578ADBCAA1DE677LL ^ a == 0;
                                           ^
                                             (     )
t.c:3:44: note: place parentheses around the ^ expression to evaluate it first
  unsigned short s = ~0x4578ADBCAA1DE677LL ^ a == 0;
                                           ^
                     (                        )
t.c:3:44: warning: implicit conversion from 'long long' to 'unsigned short'
      changes value from -5005942011641849463 to 6537 [-Wconstant-conversion]
  unsigned short s = ~0x4578ADBCAA1DE677LL ^ a == 0;
                 ~   ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
2 warnings generated.


More information about the Gcc-bugs mailing list