Re: [LyX/master] Comply with rule-of-three
Vincent van Ravesteijn wrote: > Op 12-10-2015 om 4:17 schreef Scott Kostyshak: >> On Sun, Oct 11, 2015 at 11:20:15AM +0200, Georg Baum wrote: >>> commit cea2d71e641e6a4023128a367d1cd5a593ed1706 >>> Author: Georg Baum>>> Date: Sun Oct 11 11:16:09 2015 +0200 >>> >>> Comply with rule-of-three >>> >>> The rule-of-three says that if any of virtual destructor, copy >>> constructor or assignment operator needs to be manually >>> implemented, then all three should be implemented. Otherwise you >>> can get subtle bugs which can be difficult to find. In the changed >>> classes, changing a copy-construction to an assignment would have >>> had surprising effects. Now they all behave consistently. > >> Is there any automatic check of the rule-of-three (e.g. by cppcheck or >> Coverity)? I don't think so. I found these while working on bug 7404. > What about declaring the unimplemented 'others' as private, but leaving > them unimplemented (if possible) ? This prevents adding unused code to > the codebase. I did that for the cases where the additional code would have been too complicated. For the trivial cases I liked the symmetry of the two implementations, but don't have a strong opinion, so if others prefer to disable the assigment operators instead I'll change it. Georg
Re: [LyX/master] Comply with rule-of-three
Op 12-10-2015 om 4:17 schreef Scott Kostyshak: On Sun, Oct 11, 2015 at 11:20:15AM +0200, Georg Baum wrote: commit cea2d71e641e6a4023128a367d1cd5a593ed1706 Author: Georg BaumDate: Sun Oct 11 11:16:09 2015 +0200 Comply with rule-of-three The rule-of-three says that if any of virtual destructor, copy constructor or assignment operator needs to be manually implemented, then all three should be implemented. Otherwise you can get subtle bugs which can be difficult to find. In the changed classes, changing a copy-construction to an assignment would have had surprising effects. Now they all behave consistently. What about declaring the unimplemented 'others' as private, but leaving them unimplemented (if possible) ? This prevents adding unused code to the codebase. I've seen that approach to comply to the rule. Vincent
Re: [LyX/master] Comply with rule-of-three
On Mon, Oct 12, 2015 at 4:17 AM, Scott Kostyshakwrote: > On Sun, Oct 11, 2015 at 11:20:15AM +0200, Georg Baum wrote: >> commit cea2d71e641e6a4023128a367d1cd5a593ed1706 >> Author: Georg Baum >> Date: Sun Oct 11 11:16:09 2015 +0200 >> >> Comply with rule-of-three >> >> The rule-of-three says that if any of virtual destructor, copy >> constructor >> or assignment operator needs to be manually implemented, then all three >> should be implemented. Otherwise you can get subtle bugs which can be >> difficult to find. In the changed classes, changing a copy-construction >> to >> an assignment would have had surprising effects. Now they all behave >> consistently. > > Is there any automatic check of the rule-of-three (e.g. by cppcheck or > Coverity)? > I'm not sure, but I don't think so. I did a Coverity check today, and there were 14 fixes since last check (about a month ago), most probably duplicates with cppcheck and fixed courtesy of Georg. I'm still trying to find my way around Coverity interface, but I think this is the list: https://scan4.coverity.com/reports.htm#v12247/p10234/fileInstanceId=4736058=1279561=111941 I've looked at this particular commit, however, and none of the files affected here are within the Coverity issues that were fixed. Feel free to look at them yourself in case I missed something. Looking at outstanding issues I can see however an unitialized scalar in src/insets/InsetIPA.cpp (see CID 23447) and src/insets/InsetPreview.cpp (CID 23426). Both are right above the changes by Georg. Liviu > Scott -- Do you think you know what math is? http://www.ideasroadshow.com/issues/ian-stewart-2013-08-02 Or what it means to be intelligent? http://www.ideasroadshow.com/issues/john-duncan-2013-08-30 Think again: http://www.ideasroadshow.com/library
Re: [LyX/master] Comply with rule-of-three
On Sun, Oct 11, 2015 at 11:20:15AM +0200, Georg Baum wrote: > commit cea2d71e641e6a4023128a367d1cd5a593ed1706 > Author: Georg Baum> Date: Sun Oct 11 11:16:09 2015 +0200 > > Comply with rule-of-three > > The rule-of-three says that if any of virtual destructor, copy constructor > or assignment operator needs to be manually implemented, then all three > should be implemented. Otherwise you can get subtle bugs which can be > difficult to find. In the changed classes, changing a copy-construction to > an assignment would have had surprising effects. Now they all behave > consistently. Is there any automatic check of the rule-of-three (e.g. by cppcheck or Coverity)? Scott