[Bug objc/103639] [REGRESSION] GCC 11.2 (or even earlier) breaks switch case with break in fast enumeration loop

2021-12-09 Thread js-gcc at webkeks dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103639

js-gcc at webkeks dot org changed:

   What|Removed |Added

   Keywords|wrong-code  |

--- Comment #4 from js-gcc at webkeks dot org ---
Sure:

#import 

int
main()
{
OFArray *array = [OFArray arrayWithObjects: @"a", @"b", nil];
int someVar = 0;
for (id object in array) {
switch (someVar) {
case 0:
OFLog(@"%@", object);
break;
}
OFLog(@"foo");
}

return 0;
}

Sorry, but something free-standing isn't possible as you need a collection
object. The same code should work with GNUstep by just replacing OF with NS.

[Bug objc/103639] [REGRESSION] GCC 11.2 (or even earlier) breaks switch case with break in fast enumeration loop

2021-12-09 Thread js-gcc at webkeks dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103639

--- Comment #2 from js-gcc at webkeks dot org ---
Oh, forgot to clarify in the example:

Assume more than 1 object in the collection and someVar to be 0.

[Bug objc/103639] [REGRESSION] GCC 11.2 (or even earlier) breaks switch case with break in fast enumeration loop

2021-12-09 Thread js-gcc at webkeks dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103639

js-gcc at webkeks dot org changed:

   What|Removed |Added

 CC||js-gcc at webkeks dot org

--- Comment #1 from js-gcc at webkeks dot org ---
Can confirm the same happens with 11.1.0. 10.2 seems to be fine.

[Bug objc/103639] New: [REGRESSION] GCC 11.2 (or even earlier) breaks switch case with break in fast enumeration loop

2021-12-09 Thread js-gcc at webkeks dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103639

Bug ID: 103639
   Summary: [REGRESSION] GCC 11.2 (or even earlier) breaks switch
case with break in fast enumeration loop
   Product: gcc
   Version: 11.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: objc
  Assignee: unassigned at gcc dot gnu.org
  Reporter: js-gcc at webkeks dot org
  Target Milestone: ---

The following code is miscompiled by GCC 11.2.1. I don't know when this
started, but this is a regression and used to work just fine in older version:

for (id object in someCollection) {
  switch (someVar) {
  case 0:
 puts("0");
 break;
  }
  puts("this should print but doesn't");
}

The break breaks out of the for loop instead of the switch case.

Changing the code to this makes it work:

for (id object in someCollection) {
  if (someVar == 0) {
 puts("0");
 break;
  }
  puts("this should print and does");
}

This worked just fine with older GCC versions and also works fine with all
versions of Clang.