[Bug tree-optimization/80147] missing maybe-uninitialized warning on variable with no side effects
vincent-gcc at vinc17 dot net
gcc-bugzilla@gcc.gnu.org
Wed Nov 8 01:58:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80147
Vincent Lefèvre <vincent-gcc at vinc17 dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |NEW
Resolution|INVALID |---
--- Comment #3 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
(In reply to Manuel López-Ibáñez from comment #2)
> Because "is-used" is given before optimization, while may-be-used are given
> after optimization. I don't think this is a bug, but expected behaviour
> given that optimization should allow more precise warnings (hence,
> discarding a false positive).
No, this is not a false positive. Even though f1 doesn't use its parameter, the
argument is evaluated, and if the value is a trap representation (which is
possible for some architectures), the behavior is undefined (6.2.6.1#5). Thus
the calls f1(i1) and f1(j1) are possibly incorrect.
Or even on common architectures... Consider the following code:
void f (int b)
{
double x, y;
(void) (x * x);
if (b)
(void) (y * y);
}
If x or y is a signaling NaN, this could raise the invalid exception, which
could mean a possible trap. But the warnings are always missing.
Same issue with:
void f (int b)
{
int x, y;
(void) (x / x);
if (b)
(void) (y / y);
}
Clang 4.0 gives warnings as expected.
More information about the Gcc-bugs
mailing list