Boost logo

Boost :

Subject: Re: [boost] [boost::noncopyable] compiler warnings with the -Weffc++ flags
From: David Abrahams (dave_at_[hidden])
Date: 2009-06-12 14:34:24


on Thu Jun 11 2009, Steven Watanabe <watanabesj-AT-gmail.com> wrote:

> AMDG
>
> Anand Lakshminath wrote:
>> Deriving from the boost::noncopyable class generates warnings when I
>> compile with the -Weffc++ (effective C++) flags.
>>
>> There are two types of warnings:
>>
>> <snip>
>> g++ -I/vobs/3rdparty/BOOST/boost_1_38_0/boost_inc -Weffc++ main.cpp
>> main.cpp:10: warning: base class 'class
>> boost::noncopyable_::noncopyable' has a non-virtual destructor
>>
>
> If you're planning on using Boost at all, you should disable this warning.
> Many Boost libraries use inheritance without virtual destructors heavily
> and gcc doesn't make it easy to selectively disable spurious warnings.
>
>> main.cpp:10: warning: 'class<unnamed>::DontTreadOnMe' has pointer data members
>> main.cpp:10: warning: but does not override
>> '<unnamed>::DontTreadOnMe(const <unnamed>::DontTreadOnMe&)'
>> main.cpp:10: warning: or 'operator=(const <unnamed>::DontTreadOnMe&)'
>>
>> Is there a workaround and/or fix? I am using gcc 4.0.1.
>>
>
> Um. Don't use -Weffc++? Seriously, the code is not broken and
> there's nothing we can do to prevent these warnings.

Yeah, that's a dumb warning unless you're doing strictly traditional OO
and nothing else (and not using any libraries that do anything else).
At the *very least* using private derivation should suppress it.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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