Gmane
From: David Abrahams <dave <at> boost-consulting.com>
Subject: Re: Supressing warnings
Newsgroups: gmane.comp.lib.boost.devel
Date: 2006-06-28 04:01:42 GMT (2 years, 21 weeks, 9 hours and 17 minutes ago)
Oliver Kullmann <O.Kullmann <at> swansea.ac.uk> 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

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost