public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/47783] New: Warning 'set but not used' [-Wunused-but-set-parameter] incorrectly issued for update through reference wrapper
@ 2011-02-17 14:32 dev.lists at jessamine dot co.uk
  2011-02-17 14:56 ` [Bug c++/47783] [4.6 Regression] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: dev.lists at jessamine dot co.uk @ 2011-02-17 14:32 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Warning 'set but not used'
                    [-Wunused-but-set-parameter] incorrectly issued for
                    update through reference wrapper
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dev.lists@jessamine.co.uk


Compiling the following program with warning options -W -Wall yields
<stdin>: In function ‘void f(ref_wrapper)’:
<stdin>:6:6: warning: parameter ‘ref’ set but not used
[-Wunused-but-set-parameter]

If the reference-to-int is replaced with a pointer-to-int and dereference and
address-of operators are used in the appropriate places the warning does not
occur.

In all cases and at all optimization levels the resulting program returns 7 as
expected.


struct ref_wrapper
{
   int& i;
};

void f( ref_wrapper ref )
{
   ref.i = 7;
}

int main()
{
   int x = 1;
   ref_wrapper xref = {x};
   f(xref);
   return x;
}


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

end of thread, other threads:[~2011-02-17 20:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-17 14:32 [Bug c++/47783] New: Warning 'set but not used' [-Wunused-but-set-parameter] incorrectly issued for update through reference wrapper dev.lists at jessamine dot co.uk
2011-02-17 14:56 ` [Bug c++/47783] [4.6 Regression] " redi at gcc dot gnu.org
2011-02-17 15:39 ` rguenth at gcc dot gnu.org
2011-02-17 15:50 ` paolo.carlini at oracle dot com
2011-02-17 17:56 ` jakub at gcc dot gnu.org
2011-02-17 20:49 ` jakub at gcc dot gnu.org
2011-02-17 20:53 ` jakub at gcc dot gnu.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).