On May 30, 2011, at 2:49 PM, Eli Friedman wrote: > On Mon, May 30, 2011 at 2:40 PM, Argyrios Kyrtzidis <[email protected]> wrote: >> On May 30, 2011, at 2:36 PM, Argyrios Kyrtzidis wrote: >> >> Hi Nico, >> On May 30, 2011, at 12:19 PM, Nico Weber wrote: >> >> Hi Argyrios and Matthieu, >> this warning found a few problems in chromium – thanks! However, it also >> finds a few false positives, so I don't think I can turn it on by default, >> which is a bummer. >> All of the false positives are of this form: >> class SomeInterface { >> public: >> virtual void interfaceMethod() {} // or = 0; >> protected: >> ~SomeInterface() {} >> } >> class WorkerClass : public SomeInterface { >> public: >> // many non-virtual functions, but also: >> virtual void interfaceMethod() override { /* do actual work */ } >> }; >> void f() { >> scoped_ptr<WorkerClass> c(new WorkerClass); // simplified example >> } >> This is a somewhat standard pattern (see >> e.g. http://www.gotw.ca/publications/mill18.htm, "Virtual Question #2"). >> Do you have any good suggestions how to deal with this case? >> >> If WorkerClass gets subclassed in the future, deletion in "f()" will be >> undefined behavior. Ideally WorkerClass should be marked "final" and then >> there will also be no warning; does this sound reasonable ? >> >> Um, to be exact, undefined behavior if you delete a WorkerClass * pointer. > > Sure, except that there isn't any way to do that outside of C++0x mode. :) >
We actually accept final and override as C++0x extensions even outside of C++0x. - Anders > -Eli > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
