public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "js-gcc at webkeks dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug objc/103639] New: [REGRESSION] GCC 11.2 (or even earlier) breaks switch case with break in fast enumeration loop
Date: Thu, 09 Dec 2021 20:59:51 +0000	[thread overview]
Message-ID: <bug-103639-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2021-12-09 20:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09 20:59 js-gcc at webkeks dot org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-103639-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).