Bug 11677 - Incorrect warning with -Wunused-value
Summary: Incorrect warning with -Wunused-value
Status: RESOLVED DUPLICATE of bug 11512
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-26 23:21 UTC by Weiss
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Weiss 2003-07-26 23:21:48 UTC
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
Comment 1 Andrew Pinski 2003-07-26 23:26:14 UTC
This bug is a dup of bug 11512 (which almost have the exact source).

*** This bug has been marked as a duplicate of 11512 ***