From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2961 invoked by alias); 28 Jul 2005 17:22:12 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 2395 invoked by uid 48); 28 Jul 2005 17:21:37 -0000 Date: Thu, 28 Jul 2005 17:27:00 -0000 From: "trt at acm dot org" To: gcc-bugs@gcc.gnu.org Message-ID: <20050728172131.23113.trt@acm.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c/23113] New: The -Wunused (value computed is not used) option missed an important case X-Bugzilla-Reason: CC X-SW-Source: 2005-07/txt/msg03737.txt.bz2 List-Id: The following program, compiled with gcc -Wunused, issues no warnings int foo (void); void bar (int *p) { *p++; /* perhaps (*p)++ was intended? */ foo () + foo (); foo () + foo (), foo (); } (gcc 2.9.6 issues warnings for all three lines) I have found *p++; to be a fairly common error. When sizeof(*p) == 1 or (*p)++ is illegal this is usually a superfluous `*', but otherwise it is quite often a real bug and so there should be a warning. I don't care much about things like 3+foo(), but mention them because of this inoperative comment in c-typeck.c /* With -Wunused, we should also warn if the left-hand operand does have side-effects, but computes a value which is not used. For example, in `foo() + bar(), baz()' the result of the `+' operator is not used, so we should issue a warning. */ It looks like this code in stmt.c needs yet more tweaking: maybe_warn: /* If this is an expression with side effects, don't warn. */ if (TREE_SIDE_EFFECTS (exp)) return 0; -- Summary: The -Wunused (value computed is not used) option missed an important case Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: trt at acm dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23113