[Bug c++/22406] -Weffc++ warns about missing op= and copy ctor, even when base classes have already disabled these

michal017 at centrum dot sk gcc-bugzilla@gcc.gnu.org
Mon Jan 23 12:50:00 GMT 2006



------- Comment #3 from michal017 at centrum dot sk  2006-01-23 12:50 -------
(In reply to comment #2)
> Hmm, I get only warning for this code:
> t.cc:10: warning: base class �class Foo� has a non-virtual destructor
> 

You get the warning if you declare a constructor in the Bar class (checked with
gcc 4.0.3), so the test case is:

--snip--
class Foo {
           Foo(const Foo&){} // disable
           Foo& operator=(const Foo&){} // disable
        public:
           Foo() {}
           ~Foo() {}
};

class Bar : public Foo {
        public:
                Bar() {}
        private:
                void * mPointerMember;
};

int main(void)
{
        return 0;
}

$ g++ -Weffc++ b.cc
b.cc:9: warning: base class 'class Foo' has a non-virtual destructor
b.cc:9: warning: 'class Bar' has pointer data members
b.cc:9: warning:   but does not override 'Bar(const Bar&)'
b.cc:9: warning:   or 'operator=(const Bar&)'
--snip--


-- 

michal017 at centrum dot sk changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |michal017 at centrum dot sk


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



More information about the Gcc-bugs mailing list