public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "greenfoo at u92 dot eu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/105598] New: Flag -O2 causes code to misbehave
Date: Fri, 13 May 2022 17:49:33 +0000 [thread overview]
Message-ID: <bug-105598-4@http.gcc.gnu.org/bugzilla/> (raw)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105598
Bug ID: 105598
Summary: Flag -O2 causes code to misbehave
Product: gcc
Version: 11.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: greenfoo at u92 dot eu
Target Milestone: ---
Created attachment 52974
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52974&action=edit
Small example that triggers the issue when using -O2 in gcc 11.x
I found a situation where the "-O2" flag was causing trouble at least in
x86_64.
The attached file "example.c" code is expected to print "4" when compiled and
executed, but it would print "2" when compiled with "-02".
This happens with gcc 11.1, 11.2 and 11.3, but works correctly with gcc 10.3
and 12.1:
> $ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp gcc:10.3 gcc -o example example.c && ./example
> 4
> $ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp gcc:11.1 gcc -o example example.c && ./example
> 2
> $ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp gcc:11.2 gcc -o example example.c && ./example
> 2
> $ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp gcc:11.3 gcc -o example example.c && ./example
> 2
> $ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp gcc:12.1 gcc -o example example.c && ./example
> 4
I don't know if this deserves further investigation. If not, please feel free
to discard this bug report.
Thanks!
next reply other threads:[~2022-05-13 17:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-13 17:49 greenfoo at u92 dot eu [this message]
2022-05-13 18:25 ` [Bug c/105598] [11 Regression] " jakub at gcc dot gnu.org
2022-05-16 8:47 ` [Bug tree-optimization/105598] " rguenth at gcc dot gnu.org
2022-05-16 8:59 ` jakub at gcc dot gnu.org
2022-05-16 9:18 ` rguenth at gcc dot gnu.org
2022-05-16 10:06 ` rguenth 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-105598-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).