public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/4210] should not warn in dead code
Date: Tue, 05 May 2020 15:43:52 +0000	[thread overview]
Message-ID: <bug-4210-4-ITzVg1Feaw@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-4210-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|should not warning with     |should not warn in dead
                   |dead code                   |code
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #34 from Martin Sebor <msebor at gcc dot gnu.org> ---
(In reply to Niels Möller from comment #32)

The front ends can eliminate simple subexpressions (as in '0 ? x >> 32 : x >>
1') but they don't do the same for statements.  Moving the warning from the
front end to some later pass would avoid diagnosing code in those cases (it
would also avoid duplicating the same code between different front ends).  The
earliest is probably gimplify.c.  That would avoid warning on statements
rendered dead as a result of constant expressions (as defined by the language)
but not those whose constant value GCC later propagates from prior assignments,
such as in

  const int zero = 0;

  unsigned 
  shift_dead (unsigned x)
  {
    if (zero)
      return x >> 32;
    else
      return x >> 1;
  }

The later the warning is moved the more statements will be eliminated as dead,
but the more other transformations will also be applied that might eliminate
the warning where it might be desirable, or perhaps even introduce it where it
wouldn't be issued otherwise.

  parent reply	other threads:[~2020-05-05 15:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-4210-4@http.gcc.gnu.org/bugzilla/>
2014-03-13  2:10 ` [Bug middle-end/4210] should not warning with " pinskia at gcc dot gnu.org
2014-08-09  6:09 ` pinskia at gcc dot gnu.org
2020-04-26 21:28 ` nisse at lysator dot liu.se
2020-05-04 20:44 ` nisse at lysator dot liu.se
2020-05-05  2:17 ` vincent-gcc at vinc17 dot net
2020-05-05 15:43 ` msebor at gcc dot gnu.org [this message]
2020-05-05 17:54 ` [Bug middle-end/4210] should not warn in " manu at gcc dot gnu.org
2020-05-05 18:26 ` nisse at lysator dot liu.se
2020-05-05 18:39 ` nisse at lysator dot liu.se
2020-05-06  8:10 ` nisse at lysator dot liu.se
2020-05-06 15:37 ` lopezibanez at gmail dot com
2020-05-06 16:27 ` egallager at gcc dot gnu.org
2020-05-06 18:44 ` nisse at lysator dot liu.se
2020-06-04 21:02 ` nisse at lysator dot liu.se
2020-06-05 11:14 ` glisse 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-4210-4-ITzVg1Feaw@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).