--- Begin Message ---
- To: Debian Bug Tracking System <submit@bugs.debian.org>
- Subject: g++-4.4: Wrong "value computed is not used" warning, when the subexpression has a leftvalue.
- From: Peter PROHLE <prohlep@math.bme.hu>
- Date: Sun, 21 Feb 2010 20:41:38 +0100
- Message-id: <20100221194138.4750.20623.reportbug@pc-56.chello.hu>
Package: g++-4.4
Version: 4.4.2-9
Severity: normal
A short example is the following, where none of the values of the two ++i
subexpresions is used inside their enclosing expression, ... and in that sense
we should get the error message twice ..., but the both values are used later,
namely the first is used at the second, and the second is used in the body of
the for loop.
$ cat test02.cxx
#include <iostream>
int main( void ) {
for ( int i=0 ; (++i)<99 , i<9 ; ++i ) {
std::cout << i << std::endl;
}
return 0;
}
$ /usr/bin/g++ --version | head -1
g++ (Debian 4.4.2-9) 4.4.3 20100108 (prerelease)
$ /usr/bin/g++ -Wall test02.cxx
test02.cxx: In function 'int main()':
test02.cxx:4: warning: value computed is not used
$ ./a.out
1
3
5
7
$
If a subexpression is anonym having address not accessible by the other parts
of the program, then it is probably true, that if that subexpression has no
effect on the enclosing expression, then the value of that subexpression is not
used at all.
However, if the values of the subexpression is stored at a lefvalues accessible
from other parts of the program, then we can not state, that the value computed
is not used.
Thanks for your voluntary efforts,
Peter PROHLE.
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32-trunk-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash
Versions of packages g++-4.4 depends on:
ii gcc-4.4 4.4.2-9 The GNU C compiler
ii gcc-4.4-base 4.4.2-9 The GNU Compiler Collection (base
ii libc6 2.10.2-2 GNU C Library: Shared libraries
ii libgmp3c2 2:4.3.2+dfsg-1 Multiprecision arithmetic library
ii libmpfr1ldbl 2.4.2-3 multiple precision floating-point
ii libstdc++6-4.4-dev 4.4.2-9 The GNU Standard C++ Library v3 (d
g++-4.4 recommends no packages.
Versions of packages g++-4.4 suggests:
pn g++-4.4-multilib <none> (no description available)
pn gcc-4.4-doc <none> (no description available)
pn libstdc++6-4.4-dbg <none> (no description available)
-- no debconf information
--- End Message ---