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

2018-02-21 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60083

Manuel López-Ibáñez  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||manu at gcc dot gnu.org
 Resolution|--- |FIXED

--- Comment #5 from Manuel López-Ibáñez  ---

This probably got fixed when early folding was fixed:

gcc 8.0 -Wsign-conversion -Wparentheses -Wall -Wextra -Wconversion gives:

:3:48: warning: suggest parentheses around comparison in operand of '^'
[-Wparentheses]
   unsigned short s = ~0x4578ADBCAA1DE677LL ^ a == 0;
  ~~^~~~
:3:44: warning: unsigned conversion from 'long long int' to 'short
unsigned int' changes value from '-5005942011641849463' to '6537' [-Woverflow]
   unsigned short s = ~0x4578ADBCAA1DE677LL ^ a == 0;
  ~~^~~~

The fix-it notes for -Wparentheses and having some warnings enabled by default
would be nice, but they are a different topic altogether.

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

2017-05-19 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60083

Martin Sebor  changed:

   What|Removed |Added

 CC||msebor at gcc dot gnu.org

--- Comment #4 from Martin Sebor  ---
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.

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

2017-05-19 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60083

--- Comment #3 from Marek Polacek  ---
Started with r139049.

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

2014-02-07 Thread chengniansun at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60083

--- Comment #1 from Chengnian Sun chengniansun at gmail dot com ---
I think the following case is similar to the reported case. The only difference
is the message content. The following case also triggers gcc -O0 to emit two
duplicate warnings. But gcc -O1 emits only one warning.

$: cat s.c
extern short fn2(short, short);
unsigned long g;
void fn1() {
  int const l = 0;
  fn2(((g = l != 0)  10LL) | 91608LL, 0);
}
$: gcc-trunk -c -Wconversion -std=c99 s.c
s.c: In function ‘fn1’:
s.c:5:7: warning: conversion to ‘short int’ alters ‘long long int’ constant
value [-Wconversion]
   fn2(((g = l != 0)  10LL) | 91608LL, 0);
   ^
s.c:5:7: warning: conversion to ‘short int’ alters ‘long long int’ constant
value [-Wconversion]
$: gcc-trunk -c -Wconversion -std=c99 s.c -O1
s.c: In function ‘fn1’:
s.c:5:7: warning: conversion to ‘short int’ from ‘long long int’ may alter its
value [-Wconversion]
   fn2(((g = l != 0)  10LL) | 91608LL, 0);
   ^
$:

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

2014-02-07 Thread mpolacek at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60083

Marek Polacek mpolacek at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2014-02-07
 CC||mpolacek at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #2 from Marek Polacek mpolacek at gcc dot gnu.org ---
Yeah, I bet we'll have tons of those ;/.