public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marc Glisse <marc.glisse@inria.fr>
To: Vishal Subramanyam <vishalsubramanyam@outlook.com>
Cc: "gcc-help@gcc.gnu.org" <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 12:25:38 +0100 (CET)	[thread overview]
Message-ID: <4f40d38e-dc36-ada8-d116-4020b5c84cfc@hippo.saclay.inria.fr> (raw)
In-Reply-To: <MA1PR0101MB15597BF355EA66AD9677C032B55D9@MA1PR0101MB1559.INDPRD01.PROD.OUTLOOK.COM>

On Sun, 23 Jan 2022, Vishal Subramanyam via Gcc-help wrote:

> is there a specific name for the type of optimization where the compiler simply decides to drop the return value.

Gcc handles this as part of dead code elimination (among others). A 
simpler example would be

int main(){ 1/0; }

which does not crash either.

If you want to make your function func opaque to the optimizers, you may 
be interested in __attribute__((noipa)). Using volatile would also avoid 
some optimizations.

-- 
Marc Glisse

  reply	other threads:[~2022-01-23 11:25 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
2022-01-23 10:50       ` Vishal Subramanyam
2022-01-23 11:25         ` Marc Glisse [this message]
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=4f40d38e-dc36-ada8-d116-4020b5c84cfc@hippo.saclay.inria.fr \
    --to=marc.glisse@inria.fr \
    --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).