1 /* PR middle-end/51782 */ 2 /* { dg-do run } */ 3 /* { dg-options { "-std=gnu99" } } */ 4 5 #include <stdlib.h> 6 7 struct R { char r; }; 8 struct RGB { char r,g,b; }; 9 10 __flash const struct R r1 = { 12 }; 11 __flash const struct RGB r3 = { 23, 56, 78 }; 12 13 char __attribute__((noinline,noclone)) read1_bug(const __flash struct R * s)14read1_bug (const __flash struct R *s) 15 { 16 struct R t = *s; 17 return t.r; 18 } 19 20 char __attribute__((noinline,noclone)) read1_ok(const __flash struct R * s)21read1_ok (const __flash struct R *s) 22 { 23 return s->r; 24 } 25 26 char __attribute__((noinline,noclone)) read3_bug(const __flash struct RGB * s)27read3_bug (const __flash struct RGB *s) 28 { 29 struct RGB t = *s; 30 return t.r + t.g + t.b; 31 } 32 33 char __attribute__((noinline,noclone)) read3_ok(const __flash struct RGB * s)34read3_ok (const __flash struct RGB *s) 35 { 36 return s->r + s->g + s->b; 37 } 38 39 __flash const struct R * volatile p1 = &r1; 40 __flash const struct RGB * volatile p3 = &r3; 41 main(void)42int main (void) 43 { 44 if (read1_bug (p1) != read1_ok (p1)) 45 abort(); 46 47 if (read3_bug (p3) != read3_ok (p3)) 48 abort(); 49 50 exit (0); 51 } 52