https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83553
Bug ID: 83553 Summary: compiler removes body of the for-loop, although there is a case label inside Product: gcc Version: 7.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jan.dethlefs at arcor dot de Target Milestone: --- Created attachment 42952 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42952&action=edit C++ source code It seems that the complier removes the body of the for-loop completely. Obviously, because there is a constant condition that is always false. But I think this behaviour is wrong, because there is a valid case-label inside the body. The following is not working anymore. int f2(int n) { printf("f2(%d)\n", n); int x=n; switch(x){ case 0: for( x=0; false; printf("for-expression\n")){ case 2: printf("case 2-statement\n"); } } return x; } In Version 7.2.1. the statement for case 2 and the for-expression are not executed. Output> f2(0) f2(2) In Version 4.8.5. the code works as expected. Output> f2(0) f2(2) case 2-statement for-expression