http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57555
--- Comment #4 from Marc Glisse ---
The warning is correct, but it is arguably unhelpful in this case, which is
made worse by the fact that -Woverflow is enabled by default. We do not warn
for
uint8_t ret = 0;
ret += ~foo;
with -Wall -Wextra,
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57555
Jonathan Wakely changed:
What|Removed |Added
Keywords||diagnostic
Status|UNCONFIRM
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57555
--- Comment #2 from Paolo Carlini ---
Not having studied the issue in any detail, most likely the warning is fine:
all the modern compilers (gcc, ICC, clang) I have at hand warn in exactly the
same way.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57555
--- Comment #1 from Ari Sundholm ---
It seems that actually just making the variable const suffices:
uint8_t foo() {
static const uint8_t foo = 0xff;
uint8_t ret = ~foo;
return ret;
}