GCC will accept the following code without warning even with -W -Wall -ansi
-pedantic:

#include <stdio.h>

int main(void)
{
  int i;

  i = 0;
  while(1) {

    printf("%d\n", i++);

    if (i == 20) break;

  } while(i < 10);

  return 0;
}

This program will print all the way too 19 because the exit condition at the
end is ignored.


-- 
           Summary: GCC accepts invalid loop syntax
           Product: gcc
           Version: 3.4.5
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: copx at gmx dot net


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

Reply via email to