1 /* PR45070 */ 2 extern void abort(void); 3 4 struct packed_ushort { 5 unsigned short ucs; 6 } __attribute__((packed)); 7 8 struct source { 9 int pos, length; 10 int flag; 11 }; 12 fetch(struct source * p)13static void __attribute__((noinline)) fetch(struct source *p) 14 { 15 p->length = 128; 16 } 17 next(struct source * p)18static struct packed_ushort __attribute__((noinline)) next(struct source *p) 19 { 20 struct packed_ushort rv; 21 22 if (p->pos >= p->length) { 23 if (p->flag) { 24 p->flag = 0; 25 fetch(p); 26 return next(p); 27 } 28 p->flag = 1; 29 rv.ucs = 0xffff; 30 return rv; 31 } 32 rv.ucs = 0; 33 return rv; 34 } 35 main(void)36int main(void) 37 { 38 struct source s; 39 int i; 40 41 s.pos = 0; 42 s.length = 0; 43 s.flag = 0; 44 45 for (i = 0; i < 16; i++) { 46 struct packed_ushort rv = next(&s); 47 if ((i == 0 && rv.ucs != 0xffff) 48 || (i > 0 && rv.ucs != 0)) 49 abort(); 50 } 51 return 0; 52 } 53