public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "xry111 at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/114421] arm-none-eabi thumb -Os (and -O2) incorrectly optimizes out needed class member call
Date: Thu, 21 Mar 2024 20:01:15 +0000 [thread overview]
Message-ID: <bug-114421-4-xjAB1cWhFL@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114421-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114421
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xry111 at gcc dot gnu.org
--- Comment #3 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Earle F. Philhower, III from comment #2)
> Thanks very much for the fast explanation. For reference of others who
> might hit this, I see references to C11 6.8.5 pp 6 online (but of course
> it's an ISO document so not freely available).
>
> "An iteration statement whose controlling expression is not a constant
> expression, that performs no input/output operations, does not access
> volatile objects, and performs no synchronization or atomic operations in
> its body, controlling expression, or (in the case of a for statement) its
> expression-3, may be assumed by the implementation to terminate."
For this topic C++ is actually more strict than C so referring the C standard
may be still misleading.
In C++ there is no "the controlling expression is a constant expression"
exempt, so even while (true); can be optimized out. AFAIK GCC does not
optimize away while (true); in C++, but Clang is actively doing this. There is
a WG21 paper to add the constant expression exemption for C++ like C (I cannot
remember its Nxxxx ID though).
next prev parent reply other threads:[~2024-03-21 20:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-21 19:37 [Bug c++/114421] New: " earlephilhower at yahoo dot com
2024-03-21 19:43 ` [Bug c++/114421] " pinskia at gcc dot gnu.org
2024-03-21 19:53 ` earlephilhower at yahoo dot com
2024-03-21 20:01 ` xry111 at gcc dot gnu.org [this message]
2024-03-21 21:40 ` pinskia at gcc dot gnu.org
2024-03-21 21:46 ` pinskia at gcc dot gnu.org
2024-03-21 21:47 ` pinskia at gcc dot gnu.org
2024-03-21 21:48 ` pinskia 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-114421-4-xjAB1cWhFL@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).