Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2006-06-28 00:01:42


Oliver Kullmann <O.Kullmann_at_[hidden]> writes:

> On Tue, Jun 27, 2006 at 02:37:13PM +0100, Reece Dunn wrote:

>> Oliver Kullmann wrote:

>> > > NOTE: Instead of disabling the warnings, you can remove the warning by

>> > > updating the code. For example:

>> > >

>> > > void foo( int bar ){} // unreferenced parameter

>> > > void foo( int bar ){ bar; } // no warning!

>> > >

>> >

>> > this is FALSE:

>>

>> No - it is one way to prevent the bug.

>>

>

> bug ? there is no bug here.

> I guess you meant "warning" --- but your "repair" is meaningless,

> since it introduces a meaningless expression.

> And, for good reasons, g++ warns about this(!) (at least versions 4.0.2 and above):

>

> Test.cpp: In function ‘void foo(int)’:

> Test.cpp:1: warning: statement has no effect

>

>

> One should not "repair" code just because of the stupidity of one compiler.

There's nothing wrong with that in principle, We do it routinely. And

we have a standard way to suppress unused variable warnings

  template <class T> inline void suppress_unused_variable_warning(T const&) {}

  void foo( int bar ){ suppress_unused_variable_warning(bar); } // no warning!

you can also just leave out the variable name

  void foo( int ){}

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk