Update needed to binary compatibility guide for Windows?

Michael Pyne mpyne at kde.org
Mon Apr 14 02:36:13 BST 2014


Hi all,

In the past couple of days our Binary Compatibility in C++ TechBase page [1] 
was posted to Reddit [2].

That post received a response [3] which indicated that we're actually missed a 
potential source of binary incompatibility with virtual functions on Windows 
with MSVC.

Specifically, that adding an override of an existing virtual function in a 
class may cause other vtable function entries to be re-ordered. E.g. in 
something like:

class blah
{
public:
    virtual void func1(int arg);
    virtual void func2(int arg);
    virtual void func3(int arg);
};

Adding a virtual override "func2(char *arg)" to the *end* might cause the 
vftable to line up as if declared in this order:

class blah
{
public:
    virtual void func1(int arg);
    virtual void func2(int arg);
    virtual void func2(char *arg);
    virtual void func3(int arg); // moved
};

Is anyone able to confirm this behavior on Windows? If it's true, do we want 
to adopt a constraint on our handling of virtual functions in leaf classes 
based on this? (Adding virtual methods is already not permitted for non-leaf 
classes)

Regards,
 - Michael Pyne

[1] http://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C%2B%2B
[2] 
http://www.reddit.com/r/cpp/comments/22rpjd/binary_compatibility_issues_with_c/
[3] 
http://www.reddit.com/r/cpp/comments/22rpjd/binary_compatibility_issues_with_c/cgq9iyo 




More information about the kde-core-devel mailing list