This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/44362] Bogus set-but-not-used warning
- From: "jakub at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Jun 2010 13:58:13 -0000
- Subject: [Bug c++/44362] Bogus set-but-not-used warning
- References: <bug-44362-10053@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from jakub at gcc dot gnu dot org 2010-06-01 13:58 -------
More complete testcase:
/* { dg-options "-Wunused" } */
/* { dg-do compile } */
int
f1 (int u, int v)
{
int a, b, c, d, e, f, g, h, i;
a = u;
b = v;
c = u;
d = v;
e = u;
f = v;
g = u == 6 ? a : b;
h = 0 ? c : d;
i = 1 ? e : f;
return g + h + i;
}
No warnings with C, two warnings with C++, apparently because
build_conditional_expr folds the created COND_EXPR before it has been marked.
Another testcase, again, no set but not used warnings in C but some in C++.
/* { dg-options "-Wunused" } */
/* { dg-do compile } */
void
f1 (int u, int v)
{
int a, b, c, d, e, f;
a = u;
b = v;
c = u;
d = v;
e = u;
f = v;
u == 6 ? a : b; /* { dg-warning "no effect" } */
0 ? c : d; /* { dg-warning "no effect" } */
1 ? e : f; /* { dg-warning "no effect" } */
}
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44362