[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#570838: marked as done (g++-4.4: Wrong "value computed is not used" warning, when the subexpression has a leftvalue.)



Your message dated Tue, 9 Mar 2010 15:03:26 +0100
with message-id <20100309140325.GC14795@minet.uni-jena.de>
and subject line Re: Processed: tags 567695 + moreinfo unreproducible
has caused the Debian Bug report #570838,
regarding g++-4.4: Wrong "value computed is not used" warning, when the subexpression has a leftvalue.
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
570838: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=570838
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
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 ---
--- Begin Message ---
As noted before, the warning given is correct.

Warning after every assignment where the previous value has not been
used would give far too many false positives. It would also be very
difficult to track reliably. So this is not really a sensible option.

Further, the standard mandates that prefix increment yields an lvalue,
while postfix increment doesn't, so there's no problem here either.

  Falk


--- End Message ---

Reply to: