1/* PR c++/34459 */ 2 3extern void abort (void); 4extern void *memset (void *s, int c, __SIZE_TYPE__ n); 5 6struct S 7{ 8 char s[25]; 9}; 10 11struct S *p; 12 13void __attribute__((noinline,noclone)) 14foo (struct S *x, int set) 15{ 16 int i; 17 for (i = 0; i < sizeof (x->s); ++i) 18 if (x->s[i] != 0) 19 abort (); 20 else if (set) 21 x->s[i] = set; 22 p = x; 23} 24 25void __attribute__((noinline,noclone)) 26test1 (void) 27{ 28 struct S a; 29 memset (&a.s, '\0', sizeof (a.s)); 30 foo (&a, 0); 31 struct S b = a; 32 foo (&b, 1); 33 b = a; 34 b = b; 35 foo (&b, 0); 36} 37 38void __attribute__((noinline,noclone)) 39test2 (void) 40{ 41 struct S a; 42 memset (&a.s, '\0', sizeof (a.s)); 43 foo (&a, 0); 44 struct S b = a; 45 foo (&b, 1); 46 b = a; 47 b = *p; 48 foo (&b, 0); 49} 50 51void __attribute__((noinline,noclone)) 52test3 (void) 53{ 54 struct S a; 55 memset (&a.s, '\0', sizeof (a.s)); 56 foo (&a, 0); 57 struct S b = a; 58 foo (&b, 1); 59 *p = a; 60 *p = b; 61 foo (&b, 0); 62} 63 64int 65main (void) 66{ 67 test1 (); 68 test2 (); 69 test3 (); 70 return 0; 71} 72