Thanks for the reply. Regards, Rohini -----Original Message----- From: Ian Lance Taylor [mailto:iant@xxxxxxxxxx] Sent: Tuesday, July 05, 2011 12:18 AM To: Deshpande, Rohini (STSD) Cc: gcc-help@xxxxxxxxxxx Subject: Re: C++ vtable ordering "Deshpande, Rohini (STSD)" <rohini.deshpande@xxxxxx> writes: > We have introduced a new virtual function in between existing virtual functions in a Class definition. This is compiled into a library. Usually this library needs to be backward compatible. > The programs that use this library fail if they are not recompiled, even though they do not make use of this new virtual function. These programs do not derive from the Class, they just link to the library. > > Is this because of "The order of the virtual function pointers in a virtual table is the order of declaration of the corresponding member functions in the class."( Itanium C++ ABI) Probably, yes. > Now if that virtual function is moved at the end without disturbing the ordering of existing virtual functions, then the library tends to be backward compatible(not sure). The programs work with the latest library even without recompilation. So is this fix correct? Or are there any risks involved? Yes, if there are existing virtual functions, then adding a new virtual function at the end will not break the ABI for existing uses of the library. Ian