gcc/testsuite/c-c++-common/pr95237-6.c
raw| 1 | /* { dg-do run { target { i?86-*-* x86_64-*-* } } } */ |
| 2 | /* { dg-options "-O2" } */ |
| 3 | #include <stddef.h> |
| 4 | #ifdef __x86_64__ |
| 5 | # define EXP_ALIGN 8 |
| 6 | #else |
| 7 | # define EXP_ALIGN 4 |
| 8 | #endif |
| 9 | |
| 10 | struct test |
| 11 | { |
| 12 | char a; |
| 13 | long long b; |
| 14 | }; |
| 15 | struct test global_var; |
| 16 | int main() |
| 17 | { |
| 18 | struct test local_var; |
| 19 | if (__alignof__(global_var) != EXP_ALIGN |
| 20 | || __alignof__(local_var) != EXP_ALIGN |
| 21 | || offsetof(struct test, b) != EXP_ALIGN) |
| 22 | __builtin_abort(); |
| 23 | return 0; |
| 24 | } |