| 1 |
// { dg-do run { target { *-*-linux* } } } |
| 2 |
// { dg-additional-options "-fschedule-insns2 -fstrict-aliasing" } |
| 3 |
// { dg-additional-options "-lrt" } |
| 4 |
// { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } } |
| 5 |
|
| 6 |
#include <cstdint> |
| 7 |
#include <cassert> |
| 8 |
#include <time.h> |
| 9 |
struct ID { |
| 10 |
uint64_t value; |
| 11 |
}; |
| 12 |
uint64_t value(ID id) { return id.value; } |
| 13 |
uint64_t gen { 1000 }; |
| 14 |
struct Msg { |
| 15 |
uint64_t time; |
| 16 |
ID id; |
| 17 |
}; |
| 18 |
struct V { |
| 19 |
V() { } |
| 20 |
V(Msg const & msg) : msg(msg) { } |
| 21 |
Msg & get() { return msg; } |
| 22 |
Msg msg; |
| 23 |
char pad[237 - sizeof(Msg)]; |
| 24 |
}; |
| 25 |
struct T : V { using V::V; }; |
| 26 |
Msg init_msg() { |
| 27 |
Msg msg; |
| 28 |
timespec t; |
| 29 |
clock_gettime(CLOCK_REALTIME, &t); |
| 30 |
msg.time = t.tv_sec + t.tv_nsec; |
| 31 |
msg.id.value = ++gen; |
| 32 |
return msg; |
| 33 |
} |
| 34 |
int main() { |
| 35 |
T t; |
| 36 |
t = init_msg(); |
| 37 |
assert(value(t.get().id) == 1001); |
| 38 |
} |