https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78964

            Bug ID: 78964
           Summary: gcc fails to detect pointless increment
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

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.

Reply via email to