[cfe-dev] Implementation of the CGRecordLayoutBuilder for Microsoft ABI.

Francois Pichet pichet2000 at gmail.com
Mon Sep 26 16:36:47 PDT 2011


On Mon, Sep 26, 2011 at 6:52 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Mon, Sep 26, 2011 at 6:09 AM, r4start <r4start at gmail.com> wrote:
>> I really don't understand why align=4 isn't correct.
>> I always thought that #pragma pack only affects members of the structure.
>> And __declspec(align(n)) specifies the alignment for objects of type.
>> In MSVS align for B is 4 and for A is 1.
>
> The only answer I can come up with is the model MSVC uses is simply insane.
>
> One more attempt to get some sanity: does the following compile with
> MSVC?  If so, what is the output?
>
> #include <cstdio>
> class A {
>  char c;
> };
> class B : public virtual A {
>  public:
>  void *p;
> };
> B* x = new B[10];
> int main() { std::printf("%d\n", (int)(x[1].p)); }
>

it compiles and the output is 0.
not sure what you are trying to test here.




More information about the cfe-dev mailing list