------- 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