From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23294 invoked by alias); 26 Jun 2010 00:53:30 -0000 Received: (qmail 23235 invoked by uid 48); 26 Jun 2010 00:53:13 -0000 Date: Sat, 26 Jun 2010 00:53:00 -0000 Subject: [Bug c/44677] New: Warn for variables incremented but not used X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jsm28 at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-06/txt/msg02542.txt.bz2 void f (void) { int i; i = 0; i++; } seems like something a natural generalization of -Wunused-but-set-variable should warn for; the value of i is only used as part of an increment of i, so the definition and all uses of this variable could be safely removed. For a real example of this, see the variable lang_n_infiles in gcc.c:process_command (I'm testing a patch that removes that variable along with other changes). -- Summary: Warn for variables incremented but not used Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jsm28 at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44677