[Bug c/64619] No -Wsign-conversion warning

2023-01-29 Thread roman.zilka at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64619

Roman Žilka  changed:

   What|Removed |Added

 CC||roman.zilka at gmail dot com

--- Comment #5 from Roman Žilka  ---
I'm looking for a warning that will help find overflows caused by int
promotions changing the signedness from unsigned to signed, e.g.:

uint16_t a, b;
a * b;  // int is 4B, no padding

I assume -Wsign-conversion should cover this, but it isn't triggered. Neither
is -Wconversion. gcc 12.2.1 20230121.

I notice that all of the expressions mentioned previously in this bug are about
signed -> unsigned. The other direction means a warning happening for every use
of a short, char and typedefs thereof in an expression where int promotions
occur. If that's too verbose for -Wsign-conversion, a new -W switch is
appropriate.

[Bug c/64619] No -Wsign-conversion warning

2019-08-04 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64619

Eric Gallager  changed:

   What|Removed |Added

 CC||manu at gcc dot gnu.org

--- Comment #4 from Eric Gallager  ---
cc-ing "new -Wconversion" author

[Bug c/64619] No -Wsign-conversion warning

2018-07-30 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64619

Eric Gallager  changed:

   What|Removed |Added

 CC||dmalcolm at gcc dot gnu.org,
   ||dodji at gcc dot gnu.org

--- Comment #3 from Eric Gallager  ---
cc-ing diagnostics maintainers

[Bug c/64619] No -Wsign-conversion warning

2017-07-30 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64619

Eric Gallager  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-07-30
 CC||egallager at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #2 from Eric Gallager  ---
(In reply to Mikhail Maltsev from comment #1)
> Indeed, confirmed on recent revision, r219801.

Changing status to NEW then.

[Bug c/64619] No -Wsign-conversion warning

2015-01-19 Thread maltsevm at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64619

Mikhail Maltsev  changed:

   What|Removed |Added

 CC||maltsevm at gmail dot com

--- Comment #1 from Mikhail Maltsev  ---
Indeed, confirmed on recent revision, r219801.
FWIW: it affects only bitwise operations with constants and only in case when
result is wider than non-constant operand. They are handled specially in
unsafe_conversion_p (I guess, that's because bitwise AND is used frequently, so
false positives involving it should be avoided).

$ cat ./test.c
int a;
unsigned long b;

void foo()
{
  a ^ b;
  a ^ 0x1U;
  a ^ 0x1UL;
  a + 0x1U;
  a + 0x1UL;
  a & 0xULL;
  a & 0x7FFFULL;
}

$ ../obj/gcc/xgcc -B../obj/gcc -c ./test.c -Wconversion
./test.c: In function 'foo':
./test.c:6:5: warning: conversion to 'long unsigned int' from 'int' may change
the sign of the result [-Wsign-conversion]
   a ^ b;
 ^
./test.c:7:5: warning: conversion to 'unsigned int' from 'int' may change the
sign of the result [-Wsign-conversion]
   a ^ 0x1U;
 ^
./test.c:9:5: warning: conversion to 'unsigned int' from 'int' may change the
sign of the result [-Wsign-conversion]
   a + 0x1U;
 ^
./test.c:10:5: warning: conversion to 'long unsigned int' from 'int' may change
the sign of the result [-Wsign-conversion]
   a + 0x1UL;
 ^
./test.c:11:5: warning: conversion to 'long long unsigned int' from 'int' may
change the sign of the result [-Wsign-conversion]
   a & 0xULL;
 ^