From: Xi Ruoyao <xry111@mengyan1223.wang>
To: Adrian Moreno <amorenoz@redhat.com>,
Florian Weimer <fweimer@redhat.com>,
Adrian Moreno via Gcc-help <gcc-help@gcc.gnu.org>
Cc: David Brown <david.brown@hesbynett.no>
Subject: Re: broken code only when optimized "-O2"
Date: Wed, 22 Dec 2021 18:36:37 +0800 [thread overview]
Message-ID: <9eb235680e05e02f8ac6589a52d1996b3cfc0bb5.camel@mengyan1223.wang> (raw)
In-Reply-To: <c4813434-f4ba-bbf8-7d1e-71b9a5215315@redhat.com>
On Wed, 2021-12-22 at 11:34 +0100, Adrian Moreno via Gcc-help wrote:
>
>
> On 12/22/21 11:27, Florian Weimer wrote:
> > * Adrian Moreno via Gcc-help:
> >
> > > So here I do not know what the compiler would think about "pos" if
> > > it
> > > happens to point to some invalid stack address.
> >
> > In such cases, the compiler typically assumes that the code in
> > question
> > is never executed. This means that the comparison does not need to
> > be
> > performed, among other things.
> >
>
> So it wouldn't cause undefined behavior?
It *is* undefined behavior, and the compiler can remove any execution
paths which will eventually hit an undefined behavior.
--
Xi Ruoyao <xry111@mengyan1223.wang>
School of Aerospace Science and Technology, Xidian University
next prev parent reply other threads:[~2021-12-22 10:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-21 15:40 Adrian Moreno
2021-12-21 16:05 ` Stefan Ring
2021-12-21 16:13 ` Adrian Moreno
2021-12-21 16:39 ` Segher Boessenkool
2021-12-21 17:05 ` David Brown
2021-12-22 9:24 ` Adrian Moreno
2021-12-22 10:27 ` Florian Weimer
2021-12-22 10:34 ` Adrian Moreno
2021-12-22 10:36 ` Xi Ruoyao [this message]
2021-12-22 16:05 ` Adrian Moreno
2021-12-22 15:32 ` LIU Hao
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=9eb235680e05e02f8ac6589a52d1996b3cfc0bb5.camel@mengyan1223.wang \
--to=xry111@mengyan1223.wang \
--cc=amorenoz@redhat.com \
--cc=david.brown@hesbynett.no \
--cc=fweimer@redhat.com \
--cc=gcc-help@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).