smbfs bug introduced at smbfs_vnops.c:1.58
Dimitry Andric
dimitry at andric.com
Sun Apr 10 05:04:48 PDT 2005
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... :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 183 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20050410/d63688af/attachment.bin
More information about the freebsd-fs
mailing list