https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78964
Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |trippels at gcc dot gnu.org
--- Comment #1 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
(In reply to David Binderman from comment #0)
> Given the following C / C++ code:
>
> extern void g( int);
>
> void f( int n)
> {
> int m = 0;
>
> for (int i = 0; i < n; ++i)
> {
> g(i);
> ++m;
> }
> }
>
> gcc trunk dated 20161231 fails to detect that m can be safely removed:
>
> $ ~/gcc/results/bin/gcc -c -g -O2 -Wall -Wextra jan02.cc
> $
>
> I think fixing this bug report will find about 100 bugs
> in the linux kernel.
I can see no bug. The compiler will of course eliminate the pointless ++m.
Why should it warn?