https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44677
Vincent Lefèvre <vincent-gcc at vinc17 dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vincent-gcc at vinc17 dot net
--- Comment #17 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
(In reply to Martin Sebor from comment #10)
> $ cat pr95217.c && clang -S -Wall -Wextra --analyze pr95217.c
[...]
> pr95217.c:8:3: warning: Value stored to 'p' is never read
> p += 1; // missing warning
> ^ ~
> pr95217.c:13:3: warning: Value stored to 'p' is never read
> p = p + 1; // missing warning
> ^ ~~~~~
> 2 warnings generated.
Clang (15 and above) with -Wunused-but-set-variable now detects the issue on
the "p++" and "p += 1" forms (ditto with other combined assignment operators),
but not on "p = p + 1".
Such forms (p++, etc.) are common, so that detecting an unused variable is very
useful.
Like Paul did for Emacs (comment 13), I've just fixed two issues in GNU MPFR
(one cosmetic about a useless loop variable and one important in the
testsuite), found with Clang 16. The references:
https://gitlab.inria.fr/mpfr/mpfr/-/commit/4c110cf4773b3c07de2a33acbee591cedb083c80
https://gitlab.inria.fr/mpfr/mpfr/-/commit/b34d867fa41934d12d0d4dbaaa0242d6d3eb32c7
For the second MPFR issue, there was an "err++" for each error found by the
function in the testsuite, but err was not tested at the end, so that potential
errors were never reported.