public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Possible wrong-code bug in GCC?
@ 2022-08-02  3:23 Haoxin Tu
  2022-08-02  4:44 ` Haoxin Tu
  0 siblings, 1 reply; 3+ messages in thread
From: Haoxin Tu @ 2022-08-02  3:23 UTC (permalink / raw)
  To: GCC Mailing List

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

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

end of thread, other threads:[~2022-08-02  6:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-02  3:23 Possible wrong-code bug in GCC? Haoxin Tu
2022-08-02  4:44 ` Haoxin Tu
2022-08-02  6:35   ` Jonathan Wakely

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).