From owner-freebsd-fs@FreeBSD.ORG Sun Apr 10 12:04:48 2005 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 654A116A4CE; Sun, 10 Apr 2005 12:04:48 +0000 (GMT) Received: from tensor.xs4all.nl (tensor.xs4all.nl [194.109.160.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id B785643D2F; Sun, 10 Apr 2005 12:04:47 +0000 (GMT) (envelope-from dimitry@andric.com) Received: from kilgore.dim (kilgore.dim [192.168.0.3]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by tensor.xs4all.nl (Postfix) with ESMTP id 0474622867; Sun, 10 Apr 2005 14:04:44 +0200 (CEST) Date: Sun, 10 Apr 2005 14:04:23 +0200 From: Dimitry Andric X-Priority: 3 (Normal) Message-ID: <1892195662.20050410140423@andric.com> To: Daniel Ellard In-Reply-To: <20050410074009.N66651@bowser.eecs.harvard.edu> References: <200504100251.j3A2pLEH055107@sana.init-main.com> <20050410092417.GA774@galgenberg.net> <20050410074009.N66651@bowser.eecs.harvard.edu> MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="----------1291C69219E9F339" cc: freebsd-fs@freebsd.org cc: bp@freebsd.org cc: Ulrich Spoerlein cc: freebsd-current@freebsd.org Subject: Re: smbfs bug introduced at smbfs_vnops.c:1.58 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2005 12:04:48 -0000 ------------1291C69219E9F339 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit On 2005-04-10 at 13:45:50 Daniel Ellard wrote: >> int main(void) { >> int a; >> a+=1; >> return (0); >> } [snip] > If you change the -O to -g, then the code for "a" is not > removed -- but there's still no warning. I think this is > a bug, because if the expression wasn't an innocuous a+=1 > it could be a real problem if the variable wasn't removed. The idea here is that gcc sees that the value of a is never used, and therefore it doesn't have to warn. (Whether you agree with this, or not, is more of a political or philosophical question. ;) But as soon as you actually *do* something with a's value afterwards, it will start to complain. IOW, if you change main into: int main(void) { int a; a += 1; a++; //...bunch of other operations on a... ++a; a *= 3; return 0; } and gcc will still issue no warning. However, add one actual *use* of a: extern void f(int i); int main(void) { int a; a += 1; f(a); return 0; } and you'll get the warning you want... :) ------------1291C69219E9F339 Content-Type: application/pgp-signature -----BEGIN PGP MESSAGE----- Version: GnuPG v1.4.0 (MingW32) iD8DBQFCWRZHsF6jCi4glqMRAlQwAKCcHtIlJkcR3rdp2N99qz6JimAGLwCcDisx Xiqm/Q0yy9TeULi2QHQnwts= =hO98 -----END PGP MESSAGE----- ------------1291C69219E9F339--