| 1 |
// PR tree-optimization/81365 |
| 2 |
// { dg-do run } |
| 3 |
|
| 4 |
struct A { unsigned a; }; |
| 5 |
|
| 6 |
struct B { |
| 7 |
B (const A *x) |
| 8 |
{ |
| 9 |
__builtin_memcpy (b, x, 3 * sizeof (A)); |
| 10 |
__builtin_memcpy (c, x + 3, sizeof (A)); |
| 11 |
__builtin_memset (c + 1, 0, sizeof (A)); |
| 12 |
} |
| 13 |
bool |
| 14 |
foo (unsigned x) |
| 15 |
{ |
| 16 |
A *it = c; |
| 17 |
if (it->a == x || (++it)->a == x) |
| 18 |
{ |
| 19 |
A t(b[0]); |
| 20 |
b[0] = *it; |
| 21 |
*it = t; |
| 22 |
return true; |
| 23 |
} |
| 24 |
return false; |
| 25 |
} |
| 26 |
A b[3]; |
| 27 |
A c[2]; |
| 28 |
}; |
| 29 |
|
| 30 |
int |
| 31 |
main () |
| 32 |
{ |
| 33 |
A x[] = { 4, 8, 12, 18 }; |
| 34 |
B y(x); |
| 35 |
if (!y.foo (18)) |
| 36 |
__builtin_abort (); |
| 37 |
if (!y.foo (4)) |
| 38 |
__builtin_abort (); |
| 39 |
} |