gcc/testsuite/g++.dg/abi/packed1.C
raw| 1 | // PR c++/41788 |
| 2 | // { dg-do run } |
| 3 | // { dg-options "-Wpacked -Wno-attributes" } |
| 4 | |
| 5 | extern "C" void abort (); |
| 6 | |
| 7 | struct INNER { |
| 8 | virtual int foo() const { return 1; } |
| 9 | } __attribute__ ((packed)); |
| 10 | |
| 11 | struct OUTER { |
| 12 | char c; |
| 13 | INNER inner; |
| 14 | } __attribute__ ((packed)); |
| 15 | |
| 16 | int main() |
| 17 | { |
| 18 | OUTER outer; |
| 19 | int s = sizeof(outer); |
| 20 | int o = (char *)&outer.inner - (char *)&outer; |
| 21 | if (s != sizeof (char) + sizeof (void*) |
| 22 | || o != sizeof (char)) |
| 23 | abort (); |
| 24 | } |