[cfe-dev] Different class layouts between clang and MSVC
John McCall
rjmccall at apple.com
Mon Sep 5 10:58:35 PDT 2011
On Sep 5, 2011, at 8:50 AM, Don Williamson wrote:
> One other failure has turned up in my testing:
>
> struct G
> {
> virtual ~G() { }
> int a;
> // double b;
> };
>
> As it stands, the offset of a is 4 with both compilers. When any double-parameters are introduced (uncomment b above), MSVC places a at 8 and clang keeps it at 4 - MSVC is padding up from the vtable ptr to a. It obviously then has to shift b up and results in an object that's 8 bytes larger.
Bizarre.
> Is there any use/interest in having clang and MSVC match up? Obviously it's of interest to me, but it'd be nice to know the bigger picture :)
Our intent when compiling for the MS ABI is to exactly match MSVC's layout. Obviously, that's still a work in progress. :)
If you're interested in working on this, that would be great; I don't know of anyone else currently doing it. You seem to have done a good job debugging them so far.
At the very least, please file bugs as you find these problems; it's easy for things to get lost when they're just on the mailing list.
John.
More information about the cfe-dev
mailing list