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: unassig...@gcc.gnu.org ReportedBy: dev.li...@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; }