public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug objc/103639] New: [REGRESSION] GCC 11.2 (or even earlier) breaks switch case with break in fast enumeration loop
@ 2021-12-09 20:59 js-gcc at webkeks dot org
  2021-12-09 21:05 ` [Bug objc/103639] " js-gcc at webkeks dot org
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: js-gcc at webkeks dot org @ 2021-12-09 20:59 UTC (permalink / raw)
  To: 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.

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2022-01-24  9:31 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09 20:59 [Bug objc/103639] New: [REGRESSION] GCC 11.2 (or even earlier) breaks switch case with break in fast enumeration loop js-gcc at webkeks dot org
2021-12-09 21:05 ` [Bug objc/103639] " js-gcc at webkeks dot org
2021-12-09 21:11 ` js-gcc at webkeks dot org
2021-12-09 21:42 ` pinskia at gcc dot gnu.org
2021-12-09 21:44 ` js-gcc at webkeks dot org
2021-12-10  1:40 ` egallager at gcc dot gnu.org
2021-12-10  8:17 ` iains at gcc dot gnu.org
2021-12-10  8:41 ` [Bug objc/103639] [11/12 Regression] switch case with break in fast enumeration loop generates wrong code iains at gcc dot gnu.org
2021-12-10  9:52 ` iains at gcc dot gnu.org
2021-12-10 20:43 ` pinskia at gcc dot gnu.org
2021-12-29 15:19 ` jakub at gcc dot gnu.org
2021-12-29 15:31 ` jakub at gcc dot gnu.org
2021-12-29 15:36 ` iains at gcc dot gnu.org
2021-12-29 16:22 ` jakub at gcc dot gnu.org
2021-12-29 19:59 ` iains at gcc dot gnu.org
2021-12-29 20:29 ` iains at gcc dot gnu.org
2021-12-29 20:30 ` jakub at gcc dot gnu.org
2021-12-29 20:35 ` iains at gcc dot gnu.org
2022-01-01  5:32 ` cvs-commit at gcc dot gnu.org
2022-01-04  9:11 ` [Bug objc/103639] [11 " rguenth at gcc dot gnu.org
2022-01-24  9:21 ` cvs-commit at gcc dot gnu.org
2022-01-24  9:29 ` jakub at gcc dot gnu.org
2022-01-24  9:31 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).