New proposal has been uploaded to mantis 1308 to reflect changes to "pure virtual" syntax and to match C++ as stated below. ________________________________ From: Arturo Salz [mailto:Arturo.Salz@synopsys.com] Sent: Monday, February 13, 2006 10:17 AM To: Neil.Korpusik@Sun.com; Vreugdenhil, Gordon Cc: Rich, Dave; sv-ec@eda.org Subject: RE: [sv-ec] Abstract classes and virtual methods Neil, Just so we are all in synch on the issue of overriding virtual functions. This is what the 2003 ISO/IEC C++ standard says: If a virtual member function vf is declared in a class Base and in a class Derived, derived directly or indirectly from Base, a member function vf with the same name and same parameter list as Base::vf is declared, then Derived::vf is also virtual (whether or not it is so declared) and it overrides Base::vf. And, barring some other bug, this is the way in which Vera should behave. For the record, I believe that allowing an override of a virtual function with a non-virtual is a poor design feature that violates the assumptions of the base class and is likely to cause more problems. If we do not enforce this behavior then I would be in favor of an error. Arturo -----Original Message----- From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of Neil Korpusik Sent: Monday, February 13, 2006 9:26 AM To: Gordon Vreugdenhil Cc: Rich, Dave; sv-ec@eda.org Subject: Re: [sv-ec] Abstract classes and virtual methods Gordon Vreugdenhil wrote On 02/04/06 21:34,: >>4. Optional 'virtual' keyword >> >> Page 2, first paragraph. >> >> "Once a method has been identified as virtual, it shall remain virtual in >> any subclass that overrides it. The virtual keyword may be used in later >> declarations, but is not required." >> >> This appears to be an enhancement. Not only that, I don't believe that we >> want to add this capability. It should be up to the user to determine if >> a method should be virtual or not. >> >>Neil > > > > Neil, do I understand that you want to require the user to > have an explicit "virtual" in every derivative class? Yes, that is what I proposed. > What > if the user does not use the word "virtual" if the base has > a virtual method? Does that hide the inherited one or is that > an error? It would not be an error to leave off the word 'virtual' in a subclass. It would override the virtual method in the base class just like it would for any other virtual method. The difference would be that this method would no longer be virtual for any classes derrived from this subclass. > > I don't see any particular problem with not requiring "virtual" > for virtual overrides in derivative classes. > It looks like we have a choice of two existing strategies for handling this situation. I checked the 1998 version of the ISO/IEC C++ standard to see what it had to say on this matter. It was quite clear that what Dave has proposed is indeed the way that virtual member functions are handled in C++. See section 10.3 Virtual functions. I checked the OpenVera documentation but was unable to find sufficient details on this to definitively say which way it should work in Vera. I wrote a small vera example and observe that it works in a manner similar to what I was suggesting in my post to the reflector. That leaves us with two existing implemetations to coose from. Orgininally I was thinking that C++ and Vera treated virtual methods the same way. I now realize that they don't. -- --------------------------------------------------------------------- Neil Korpusik Tel: 408-720-4852 Senior Staff Engineer Fax: 408-720-4850 Frontend Technologies - ASICs & Processors (FTAP) Sun Microsystems email: neil.korpusik@sun.com ---------------------------------------------------------------------Received on Thu Mar 2 18:57:39 2006
This archive was generated by hypermail 2.1.8 : Thu Mar 02 2006 - 18:58:48 PST