| 1 |
// PR c++/98206 |
| 2 |
// { dg-do run } |
| 3 |
// { dg-options "-fsanitize=alignment -std=c++11 -fno-sanitize-recover=alignment" } |
| 4 |
|
| 5 |
template <typename Derived> |
| 6 |
struct Base1 |
| 7 |
{ |
| 8 |
char c1; |
| 9 |
}; |
| 10 |
|
| 11 |
template <typename Derived> |
| 12 |
struct Base2 |
| 13 |
{ |
| 14 |
char c2; |
| 15 |
const Derived &get2 () const { return static_cast<const Derived &> (*this); } |
| 16 |
}; |
| 17 |
|
| 18 |
struct X : public Base1<X>, public Base2<X> |
| 19 |
{ |
| 20 |
X (const char *d) : data{d} {} |
| 21 |
const char *data; |
| 22 |
}; |
| 23 |
|
| 24 |
int |
| 25 |
main () |
| 26 |
{ |
| 27 |
X x = X{"cheesecake"}; |
| 28 |
const char *p = x.get2 ().data; |
| 29 |
if (p[0] != 'c') |
| 30 |
__builtin_abort (); |
| 31 |
} |