public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Haoxin Tu <haoxintu@gmail.com>
To: GCC Mailing List <gcc@gcc.gnu.org>
Subject: Re: Possible wrong-code bug in GCC?
Date: Tue, 2 Aug 2022 12:44:09 +0800	[thread overview]
Message-ID: <CALDyosZzYJ9MTxroe9mfH+3cgmnnUUajQm6Dw+1+1W6-q6QVRA@mail.gmail.com> (raw)
In-Reply-To: <CALDyosYzvPz=R1Dbn1hi8bskgfNbc1aRN5WJptYmHcm9yJ2Hog@mail.gmail.com>

Oh, sorry for the noise, there is an integer overflow that may cause
undefined behavior.

Haoxin Tu <haoxintu@gmail.com> 于2022年8月2日周二 11:23写道:

> Dear developers,
>
> May I seek your confirmation to check whether the following program
> triggers a true wrong-code issue in GCC? The following piece of code looks
> too simple and I am not quite sure whether it's a bug or not.
>
> Here is the test program (s.c):
> ```
> int a = 0, b = 0;
> int main() {
> for (; a <= 6; a++) {
> c:
> b++;
> if (b) {
> goto c;
> }
> }
> return 0;
> }
>
> ```
> $ gcc-trunk  -O1 s.c ; ./a.out
> (infinite loop)
> $ gcc-trunk -O2 s.c ;./a.out
>
> Godbolt: https://godbolt.org/z/dx6efvv7x
>
> I guess the behavior of -O2 is normal as the if statement inside the
> for-loop will be 0 after certain iterations. It's worth noting that almost
> all versions of GCC behave the same in this case. Also, note that LLVM
> behaves the same under the two optimization options; they all terminate the
> execution in seconds.
>
> So, before I make any noise in the GCC bug repo, may I quickly check with
> you and see whether the `s.c` is a potential wrong code bug in GCC, or
> did I miss any important information here? I will file a new bug report
> for this issue if it is a true bug.
>
> Thank you so much and looking forward to your reply!
>
>
> Best regards,
> Haoxin
>

  reply	other threads:[~2022-08-02  4:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-02  3:23 Haoxin Tu
2022-08-02  4:44 ` Haoxin Tu [this message]
2022-08-02  6:35   ` Jonathan Wakely

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=CALDyosZzYJ9MTxroe9mfH+3cgmnnUUajQm6Dw+1+1W6-q6QVRA@mail.gmail.com \
    --to=haoxintu@gmail.com \
    --cc=gcc@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).