aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/abi/layout2.C
blob: d9ccda8a0744bee1762c8df0fe3b282650517039 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Red Hat bugzilla 65210
// { dg-do run }
// APPLE LOCAL Apple has specific long double warning message then FSF
// { dg-options "-Wno-long-double" { target *-apple-darwin* } } 

struct A {
    int a;
};

struct B : public virtual A {};

struct C {
  long double c;
};

struct D : public virtual C {
    int d;
};

struct E : public B, public D {
    int e;
};

E e;

/* The layout of E should begin with the B-in-E vtable pointer, followed by
   the D-in-E vtable pointer.  The bug was that we used to pad out the D
   fields for long double alignment.  */

int main ()
{
  D* dp = &e;
  unsigned long d_offset = ((char*)dp) - ((char*) &e);
  return (d_offset != sizeof(void *));
}