public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vincent-gcc at vinc17 dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/52106] warning for useless assignments
Date: Fri, 03 Feb 2012 13:29:00 -0000	[thread overview]
Message-ID: <bug-52106-4-PYBtaqO07n@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-52106-4@http.gcc.gnu.org/bugzilla/>

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

Vincent Lefèvre <vincent-gcc at vinc17 dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |
            Summary|missing                     |warning for useless
                   |-Wunused-but-set-variable   |assignments
                   |warning with the a = b =    |
                   |... construct               |

--- Comment #2 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> 2012-02-03 13:28:39 UTC ---
Then there should be another warning. So, this is a request for a warning for
assignments that are obviously useless (thus maybe a typo in the code or old
code that could be removed...). It should cover variables set but not used
outside the full expression where they are set. The code

int foo (void)
{
  int a, b;
  a = b = 0;
  return a;
}

gives an example. It could be written:

int foo (void)
{
  int a;
  a = 0;
  return a;
}

"a = b = ...;" is generally used as a shortcut for "a = ...; b = ...;", and if
it isn't (because the behavior would be different at compile time or at run
time), there should be a warning against this construct.


  parent reply	other threads:[~2012-02-03 13:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-03 12:34 [Bug c/52106] New: missing -Wunused-but-set-variable warning with the a = b = ... construct vincent-gcc at vinc17 dot net
2012-02-03 12:54 ` [Bug c/52106] " jakub at gcc dot gnu.org
2012-02-03 13:29 ` vincent-gcc at vinc17 dot net [this message]
2012-02-03 13:33 ` [Bug c/52106] warning for useless assignments rguenth at gcc dot gnu.org
2012-02-03 17:18 ` [Bug c/52106] [C11] missing -Wunused-but-set-variable warning with the a = b = ... construct pinskia 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-52106-4-PYBtaqO07n@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).