public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/44412]  New: Another bogus set-but-not-used warning
@ 2010-06-04  0:35 paolo dot carlini at oracle dot com
  2010-06-04 12:04 ` [Bug c++/44412] [4.6 Regression] " jakub at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-06-04  0:35 UTC (permalink / raw)
  To: gcc-bugs

This one causes tons of warnings in the libstdc++ testsuite (with -Wall in
CXXFLAGS) and seems also bogus to me.

struct ratio
{
  static const int a = 3;
};

const int ratio::a;

int f()
{
  ratio r;
  return r.a;
}


-- 
           Summary: Another bogus set-but-not-used warning
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: paolo dot carlini at oracle dot com


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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/44412] [4.6 Regression] Another bogus set-but-not-used warning
  2010-06-04  0:35 [Bug c++/44412] New: Another bogus set-but-not-used warning paolo dot carlini at oracle dot com
@ 2010-06-04 12:04 ` jakub at gcc dot gnu dot org
  2010-06-04 14:13 ` jakub at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-06-04 12:04 UTC (permalink / raw)
  To: gcc-bugs



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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/44412] [4.6 Regression] Another bogus set-but-not-used warning
  2010-06-04  0:35 [Bug c++/44412] New: Another bogus set-but-not-used warning paolo dot carlini at oracle dot com
  2010-06-04 12:04 ` [Bug c++/44412] [4.6 Regression] " jakub at gcc dot gnu dot org
@ 2010-06-04 14:13 ` jakub at gcc dot gnu dot org
  2010-06-04 18:46 ` jakub at gcc dot gnu dot org
  2010-06-24 11:00 ` jakub at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-06-04 14:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jakub at gcc dot gnu dot org  2010-06-04 14:12 -------
Created an attachment (id=20838)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20838&action=view)
gcc46-pr44412.patch

Untested patch.


-- 


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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/44412] [4.6 Regression] Another bogus set-but-not-used warning
  2010-06-04  0:35 [Bug c++/44412] New: Another bogus set-but-not-used warning paolo dot carlini at oracle dot com
  2010-06-04 12:04 ` [Bug c++/44412] [4.6 Regression] " jakub at gcc dot gnu dot org
  2010-06-04 14:13 ` jakub at gcc dot gnu dot org
@ 2010-06-04 18:46 ` jakub at gcc dot gnu dot org
  2010-06-24 11:00 ` jakub at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-06-04 18:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jakub at gcc dot gnu dot org  2010-06-04 18:46 -------
Subject: Bug 44412

Author: jakub
Date: Fri Jun  4 18:45:07 2010
New Revision: 160290

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160290
Log:
        PR c++/44412
        * typeck.c (build_class_member_access_expr): Call mark_exp_read
        on object for static data members.

        * g++.dg/warn/Wunused-var-10.C: New test.
        * g++.dg/warn/Wunused-var-11.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/warn/Wunused-var-10.C
    trunk/gcc/testsuite/g++.dg/warn/Wunused-var-11.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/44412] [4.6 Regression] Another bogus set-but-not-used warning
  2010-06-04  0:35 [Bug c++/44412] New: Another bogus set-but-not-used warning paolo dot carlini at oracle dot com
                   ` (2 preceding siblings ...)
  2010-06-04 18:46 ` jakub at gcc dot gnu dot org
@ 2010-06-24 11:00 ` jakub at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-06-24 11:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jakub at gcc dot gnu dot org  2010-06-24 11:00 -------
Fixed.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-06-24 11:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-04  0:35 [Bug c++/44412] New: Another bogus set-but-not-used warning paolo dot carlini at oracle dot com
2010-06-04 12:04 ` [Bug c++/44412] [4.6 Regression] " jakub at gcc dot gnu dot org
2010-06-04 14:13 ` jakub at gcc dot gnu dot org
2010-06-04 18:46 ` jakub at gcc dot gnu dot org
2010-06-24 11:00 ` jakub at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).