Date: Sun, 10 Apr 2005 14:04:23 +0200 From: Dimitry Andric <dimitry@andric.com> To: Daniel Ellard <ellard@eecs.harvard.edu> Cc: freebsd-current@freebsd.org Subject: Re: smbfs bug introduced at smbfs_vnops.c:1.58 Message-ID: <1892195662.20050410140423@andric.com> 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>
next in thread | previous in thread | raw e-mail | index | archive | help
------------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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1892195662.20050410140423>
