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

            Bug ID: 93432
           Summary: variable is used uninitialized, but gcc shows no
                    warning
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sven.koehler at gmail dot com
  Target Milestone: ---

Consider the following code:

int test53(int y) {
  int z;
  for (int x=0; x<10; x=x+1,y=y+1,z=z+1) {
    if (y<10) {
      continue;
    }
    z = 1;
  }
  return z;
}
int main() {
  printf("%d\n", test53(0));
  printf("%d\n", test53(5));
  printf("%d\n", test53(10));
  return 0;
}


If y < 10 in the first iteration, the variable z is used uninitialized.
Clearly, the continue can potentially skip the initialization of z.

Even if -Wall and -Wextra, gcc does not produce a warning.

Reply via email to