[Bug c/64619] No -Wsign-conversion warning
maltsevm at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Jan 20 06:43:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64619
Mikhail Maltsev <maltsevm at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |maltsevm at gmail dot com
--- Comment #1 from Mikhail Maltsev <maltsevm at gmail dot com> ---
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 & 0xFFFFFFFFULL;
a & 0x7FFFFFFFULL;
}
$ ../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 & 0xFFFFFFFFULL;
^
More information about the Gcc-bugs
mailing list