public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/64639] New: false negative of -Wunused-value
@ 2015-01-17  7:48 chengniansun at gmail dot com
  2015-01-17  8:15 ` [Bug c/64639] " chengniansun at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: chengniansun at gmail dot com @ 2015-01-17  7:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64639
           Summary: false negative of -Wunused-value
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chengniansun at gmail dot com

I think GCC should also warn that the value of the expression "(a = 0) != 0" is
not used. 

$: cat s.c
int *a;
int b;
void f() { 
  b = (0, (a = 0) != 0, 0);
}
$: 
$: gcc-trunk -c -Wunused-value s.c
s.c: In function ‘f’:
s.c:4:9: warning: left-hand operand of comma expression has no effect
[-Wunused-value]
   b = (0, (a = 0) != 0, 0);
         ^
$: 
$: clang-trunk -c -Wunused-value s.c
s.c:4:8: warning: expression result unused [-Wunused-value]
  b = (0, (a = 0) != 0, 0);
       ^
s.c:4:19: warning: expression result unused [-Wunused-value]
  b = (0, (a = 0) != 0, 0);
          ~~~~~~~ ^  ~
2 warnings generated.
$: 
$:
>From gcc-bugs-return-473635-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Jan 17 07:51:49 2015
Return-Path: <gcc-bugs-return-473635-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 27721 invoked by alias); 17 Jan 2015 07:51:49 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 27697 invoked by uid 48); 17 Jan 2015 07:51:45 -0000
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/64639] false negative of -Wunused-value
Date: Sat, 17 Jan 2015 07:51:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: pinskia at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-64639-4-EKuUD77Cfm@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64639-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64639-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-01/txt/msg01629.txt.bz2
Content-length: 234

https://gcc.gnu.org/bugzilla/show_bug.cgi?idd639

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
"(a = 0) != 0" has a side effect of setting a to 0.

I think in this case, clang is incorrectly warning about it.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-05-19 17:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-17  7:48 [Bug c/64639] New: false negative of -Wunused-value chengniansun at gmail dot com
2015-01-17  8:15 ` [Bug c/64639] " chengniansun at gmail dot com
2015-01-17 18:53 ` chengniansun at gmail dot com
2015-01-18 13:29 ` manu at gcc dot gnu.org
2015-01-20  9:32 ` maltsevm at gmail dot com
2020-05-19 17:19 ` [Bug c/64639] missing warning by -Wunused-value in compound expressions msebor at gcc dot gnu.org

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).