public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@mengyan1223.wang>
To: Vishal Subramanyam <vishalsubramanyam@outlook.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Pure/const function not getting executed as the first operand to logical OR ( || ) (C++)
Date: Sun, 23 Jan 2022 18:02:46 +0800	[thread overview]
Message-ID: <f37cb8d54e546400e7c3b1fc3d2c9d716a24bd15.camel@mengyan1223.wang> (raw)
In-Reply-To: <MA1PR0101MB15596E34BCF3E684A1468974B55D9@MA1PR0101MB1559.INDPRD01.PROD.OUTLOOK.COM>

On Sun, 2022-01-23 at 09:56 +0000, Vishal Subramanyam wrote:
> This still doesn't explain why an O1 level optimization can violate
> the standard by not evaluating the first operand.

It's not violating the standard.  The standard says division-by-zero is
an undefined behavior, so the compiler can do anything.

> What optimization is my code triggering with -fno-inline? My function
> clearly has a return value, so how did the compiler
> decide that the return value doesn't matter?

-- 
Xi Ruoyao <xry111@mengyan1223.wang>
School of Aerospace Science and Technology, Xidian University

  parent reply	other threads:[~2022-01-23 10:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-23  8:37 Vishal Subramanyam
2022-01-23  9:12 ` Xi Ruoyao
     [not found]   ` <MA1PR0101MB15596E34BCF3E684A1468974B55D9@MA1PR0101MB1559.INDPRD01.PROD.OUTLOOK.COM>
2022-01-23  9:58     ` Fw: " Vishal Subramanyam
2022-01-23 10:02     ` Xi Ruoyao [this message]
2022-01-23 10:50       ` Vishal Subramanyam
2022-01-23 11:25         ` Marc Glisse
2022-01-23 12:24           ` Vishal Subramanyam

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=f37cb8d54e546400e7c3b1fc3d2c9d716a24bd15.camel@mengyan1223.wang \
    --to=xry111@mengyan1223.wang \
    --cc=gcc-help@gcc.gnu.org \
    --cc=vishalsubramanyam@outlook.com \
    /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).