https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89425
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2019-02-21
CC| |msebor at gcc dot gnu.org
Summary|-Wabsolute-value warns in |[9 Regression]
|dead code |-Wabsolute-value warns in
| |dead subexpressions
Ever confirmed|0 |1
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed. For reference, the -Wshift-count-overflow warning handles this
correctly (of course, if still fires when the dead code is in an if statement).
Since there is a precedent/solution for avoiding these warnings in the C
front-end I suppose this bug qualifies as a 9 regression.
$ cat u.c && gcc -S -Wall -Wextra -m32 u.c
long f (long x)
{
return sizeof (x) == 8 ? x >> 63 : x >> 31; // no warning for unreachable
subexpression (good)
}
long g (long x)
{
if (sizeof (x) == 8) return x >> 63; else return x >> 31; //
-Wshift-count-overflow for unreachable statement
}
double h (double x)
{
return sizeof (x) == sizeof (float) ? __builtin_fabsf (x) : __builtin_fabs
(x); // -Wabsolute-value for unreachable subexpression
}
u.c: In function ‘g’:
u.c:8:33: warning: right shift count >= width of type [-Wshift-count-overflow]
8 | if (sizeof (x) == 8) return x >> 63; else return x >> 31;
| ^~
u.c: In function ‘h’:
u.c:13:41: warning: absolute value function ‘__builtin_fabsf’ given an argument
of type ‘double’ but has parameter of type ‘float’ which may cause truncation
of value [-Wabsolute-value]
13 | return sizeof (x) == sizeof (float) ? __builtin_fabsf (x) :
__builtin_fabs (x); // -Wabsolute-value for unreachable subexpression
| ^~~~~~~~~~~~~~~