1 /* The target must support __builtin_trap to run this test. */
2 /* { dg-do run { target i?86-* mips*-* powerpc*-* m68k-* sparc*-* i960*-* } } */
4 /* Testcase distilled from glibc's nss_parse_service_list in nss/nsswitch.c
5 It can't be distilled further. Fails with `-O2' for i[3456]86. */
7 /* this simulates a bounded-pointer type. */
8 struct ucharp
{ unsigned char *v
, *l
, *h
; };
10 /* this simulates bounded-pointer check prior to pointer dereference. */
11 #define AREF(var, idx) ((((((((var).v+(idx)) < (var).l) \
12 || (((var).v+(idx)+1) > (var).h))) \
13 && (__builtin_trap (), 0)), \
31 foo (struct ucharp cp
, struct ucharp lp
, struct list
**nextp
)
36 while (AREF (lp
, 0) && AREF (cp
, AREF (lp
, 0)))
39 while (AREF (cp
, AREF (lp
, 0)))
41 if (AREF (lp
, 0) == one
)
44 while (AREF (lp
, 0) && AREF (cp
, AREF (lp
, 0)));
45 /* The above AREF (cp, ...) fails because the pseudo created to
46 hold cp.v holds garbage, having never been set.
47 The easiest way to see the problem is to compile wiht `-O2 -da'
48 then look at *.09.loop. Search for something like this:
50 Hoisted regno 183 r/o from (mem/s:SI (reg:SI 16 argp) 10)
51 Replaced reg 91, deleting init_insn (213).
53 Now, look for the use of reg 91, which has no set. */
62 extern void exit (int);
67 static unsigned char cp0
[] = "\0\0\0\0";
68 struct ucharp cp
= { cp0
, cp0
, cp0
+ sizeof (cp0
) };
70 static unsigned char lp0
[] = "\1\1\0\0";
71 struct ucharp lp
= { lp0
, lp0
, lp0
+ sizeof (lp0
) };
74 struct list
*nextp
= &list
;