http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56672



             Bug #: 56672

           Summary: Bad optimization

    Classification: Unclassified

           Product: gcc

           Version: 4.6.3

            Status: UNCONFIRMED

          Severity: minor

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: nro...@gmail.com





Created attachment 29704

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29704

g++ -v output



For background see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36996



When compiled with -Os, the program below does not terminate. 



Here is my opinion: `mask` becomes undefined and it cause an unrelated variable

`maskI' to become undefined. If that is a valid compilation of the program, it

would make it very hard for programmers to reason about correctness.



#include <stdio.h>

int main ()

{

  int mask = 0, maskI;    

  for (maskI = 0; maskI < 4; maskI++) {              

    printf ("y %d\n", mask);

    mask += 0x55555555;

  }

  return 0;

}

Reply via email to