public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "scovich at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/55288] Improve handling/suppression of maybe-uninitialized warnings
Date: Mon, 12 Nov 2012 21:11:00 -0000	[thread overview]
Message-ID: <bug-55288-4-iAx8ZktYJx@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-55288-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55288

--- Comment #2 from Ryan Johnson <scovich at gmail dot com> 2012-11-12 21:11:43 UTC ---
(In reply to comment #1)
> Why don't just initialize the variable? It seems simpler than implementing yet
> another special attribute in GCC.

In the original program, the "variable" is a largish struct, the function is
hot, and the 'valid' execution path is not the most common one. Avoiding
unnecessary initialization there has a measurable impact on performance. 

Note that, in other parts of the code that gcc understands better, the
initialization is unnecessary (no warning) and gets optimized away even if I do
have it in place... much to my chagrin once, after I did a lot of work to
refactor a complex function, only to realize that gcc emitted *exactly* the
same machine code afterward, because it had already noticed and eliminated the
dead stores. 

There's also a philosophical argument to be made... if we agree that all
warnings subject to false positives should be supressible, the current
mechanism for maybe-uninitialized is inadequate, and a variable attribute would
resolve the issue very nicely. There's precedent for this: you *could* use
#ifndef NDEBUG (or even pragma diagnostic) to avoid unused-variable warnings
for helper variables used by multiple assertions scattered over a region of
code, but setting ((unused)) on the offending variable is much easier to read
and maintain, while still allowing other unused variables to be flagged
properly.


  parent reply	other threads:[~2012-11-12 21:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-12 18:28 [Bug c++/55288] New: " scovich at gmail dot com
2012-11-12 20:07 ` [Bug c++/55288] " manu at gcc dot gnu.org
2012-11-12 21:11 ` scovich at gmail dot com [this message]
2021-03-25 23:39 ` [Bug tree-optimization/55288] " msebor at gcc dot gnu.org
2021-04-09 17:42 ` cvs-commit at gcc dot gnu.org
2022-01-08 10:53 ` pinskia at gcc dot gnu.org
2022-02-01 22:24 ` egallager at gcc dot gnu.org
2022-09-14 13:20 ` rguenth 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-55288-4-iAx8ZktYJx@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).