[Bug c++/44412] [4.6 Regression] Another bogus set-but-not-used warning

jakub at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Jun 4 12:04:00 GMT 2010



------- Comment #1 from jakub at gcc dot gnu dot org  2010-06-04 12:03 -------
More complete testcase:

// PR c++/44412
// { dg-do compile }
// { dg-options "-Wunused" }

struct S
{
  static const int a = 3;
  static int b;
  int c;
};

const int S::a;
int S::b = 4;

int
f1 ()
{
  S s;
  return s.a;
}

int
f2 ()
{
  S s;
  return s.b;
}

void
f3 ()
{
  S s;
  s.c = 6;// { dg-warning "set but not used" }
}

int
f4 ()
{
  S s;
  s.c = 6;
  return s.c;
}

Guess we should mark the object through which a static data member is accessed,
because that access already marks the object as TREE_USED, yet it is not a set
of the object.  Not sure where to do that though.  Calling methods or static
methods apparently is handled already, in both cases build_new_method_call
-> build_this -> cp_build_unary_op ADDR_EXPR -> mark_lvalue_use ->
mark_exp_read takes care of it:

// PR c++/44412
// { dg-do compile }
// { dg-options "-Wunused" }

struct S
{
  int foo ();
  static int bar ();
};

int S::foo ()
{
  return 5;
}

int S::bar ()
{
  return 6;
}

int
f1 ()
{
  S s;
  return s.foo ();
}

int
f2 ()
{
  S s;
  return s.bar ();
}


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dodji at gcc dot gnu dot
                   |                            |org, jason at gcc dot gnu
                   |                            |dot org
            Summary|Another bogus set-but-not-  |[4.6 Regression] Another
                   |used warning                |bogus set-but-not-used
                   |                            |warning
   Target Milestone|---                         |4.6.0


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



More information about the Gcc-bugs mailing list