This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/53398] New: feature request: option for overloaded methods order in vtable compatibility with msc


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53398

             Bug #: 53398
           Summary: feature request: option for overloaded methods order
                    in vtable compatibility with msc
    Classification: Unclassified
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: sweetrommie@gmail.com


The target of this topic is about mingw and ms compiler incompatibility.

GCC places overloaded virtual functions in order they appear in class
declaration.
In opposite msc reverts them.

Assuming we have a dll compiled in msc and such header for using the dll:

class A {
 virutal void overl(void) = 0;
 virutal void fun1(void) = 0;
 virutal void overl(int i) = 0;
 virutal void overl(double d) = 0;
 virutal void fun2(void) = 0;
 virutal void overl(char *c) = 0;
};

to use it with mingw compiler we need to change it to

class A {
 virutal void overl(char *c) = 0;
 virutal void fun1(void) = 0;
 virutal void overl(double d) = 0;
 virutal void overl(int i) = 0;
 virutal void fun2(void) = 0;
 virutal void overl(void) = 0;
};

or to portable version, which removes overloading (behave gcc ordering)

class A {
 virutal void overlC(char *c) = 0;
 virutal void fun1(void) = 0;
 virutal void overlD(double d) = 0;
 virutal void overlI(int i) = 0;
 virutal void fun2(void) = 0;
 virutal void overlV(void) = 0;
};

It would be nice to have some option to just say the compiler to use different
order.
We could have an option added to a compiler like -fvisibility-ms-compat or
-fabi-version=n.
Or maybe better by something like pragma pack push, so we can do:

#pragma vtorder(push, reverted)
#include "dll_header.h"
#pragma vtorder(pop)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]