[Bug c++/11677] New: Incorrect warning with -Wunused-value

weiss at sztaki dot hu gcc-bugzilla@gcc.gnu.org
Sat Jul 26 23:21:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11677

           Summary: Incorrect warning with -Wunused-value
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: weiss at sztaki dot hu
                CC: gcc-bugs at gcc dot gnu dot org

The following code issues an incorrect warning.
Note, that the non-template version (fine) is fine.

gonzo:/tmp # cat foo.cc
template <class T>
void foo(T &a)
{
  for(int i = 0, j = 0; i != 3; ++i, ++j)
    a += j;
}

void fine(int &a)
{
  for(int i = 0, j = 0; i != 3; ++i, ++j)
    a += j;
}

int
main()
{
  return 0;
}

gonzo:/tmp # /gml/shared/gcc-cvs/bin/g++ -v
Reading specs from /gml/shared/gcc-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.4/specs
Konfiguriert mit: ../gcc/configure --prefix=/gml/shared/gcc-cvs --enable-shared
--enable-languages=c,c++ --enable-threads=posix
Thread model: posix
gcc-Version 3.4 20030726 (experimental)

gonzo:/tmp # /gml/shared/gcc-cvs/bin/g++ -Wunused-value foo.cc
foo.cc: In function `void foo(T&)':
foo.cc:4: Warnung: left-hand operand of comma expression has no effect



More information about the Gcc-bugs mailing list