| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2" } */ |
| 3 |
|
| 4 |
|
| 5 |
/* Based on the submitted test case but using types with |
| 6 |
* tags and moving the second version into another scope. */ |
| 7 |
|
| 8 |
typedef struct foo |
| 9 |
{ |
| 10 |
long coeffs; |
| 11 |
} |
| 12 |
fmpz_poly_struct; |
| 13 |
|
| 14 |
|
| 15 |
void f() |
| 16 |
{ |
| 17 |
typedef struct foo |
| 18 |
{ |
| 19 |
} n_poly_struct; |
| 20 |
typedef struct |
| 21 |
{ |
| 22 |
n_poly_struct * coeffs; |
| 23 |
long alloc; |
| 24 |
long length; |
| 25 |
} n_bpoly_struct; |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
typedef struct |
| 30 |
{ |
| 31 |
fmpz_poly_struct * coeffs; |
| 32 |
long alloc; |
| 33 |
long length; |
| 34 |
} fmpz_bpoly_struct; |
| 35 |
typedef fmpz_bpoly_struct fmpz_bpoly_t[]; |
| 36 |
|
| 37 |
__attribute__((noinline)) |
| 38 |
fmpz_poly_struct * fmpz_bpoly_swap_(fmpz_bpoly_t B, fmpz_bpoly_t Q) |
| 39 |
{ |
| 40 |
fmpz_bpoly_struct t = *B; |
| 41 |
*B = *Q; |
| 42 |
*Q = t; |
| 43 |
return B->coeffs; |
| 44 |
} |
| 45 |
|
| 46 |
__attribute__((noinline,optimize("no-strict-aliasing"))) |
| 47 |
fmpz_poly_struct * fmpz_bpoly_swap_2(fmpz_bpoly_t B, fmpz_bpoly_t Q) |
| 48 |
{ |
| 49 |
fmpz_bpoly_struct t = *B; |
| 50 |
*B = *Q; |
| 51 |
*Q = t; |
| 52 |
return B->coeffs; |
| 53 |
} |
| 54 |
|
| 55 |
int main(){ |
| 56 |
fmpz_poly_struct B_coeffs = {0}, Q_coeffs = {0}; |
| 57 |
fmpz_bpoly_t B = {0}; |
| 58 |
fmpz_bpoly_t Q = {0}; |
| 59 |
B->coeffs = &B_coeffs; |
| 60 |
Q->coeffs = &Q_coeffs; |
| 61 |
if (fmpz_bpoly_swap_(B, Q) != &Q_coeffs) |
| 62 |
__builtin_abort(); |
| 63 |
B->coeffs = &B_coeffs; |
| 64 |
Q->coeffs = &Q_coeffs; |
| 65 |
if (fmpz_bpoly_swap_2(B, Q) != &Q_coeffs) |
| 66 |
__builtin_abort(); |
| 67 |
return 0; |
| 68 |
} |
| 69 |
|