1 /* PR optimization/10392
2 * Reporter: marcus@mc.pp.se
3 * Summary: [3.3/3.4 regression] [SH] optimizer generates faulty array indexing
5 * The address calculation of an index operation on an array on the stack
6 * can _under some conditions_ get messed up completely
8 * Testcase tweaked by dank@kegel.com
9 * Problem only happens with -O2 -m4, so it should only happen on sh4,
10 * but what the heck, let's test other architectures, too.
11 * Not marked as xfail since it's a regression.
14 /* { dg-options "-O2" } */
15 /* { dg-options "-O2 -m4" { target sh4-*-* } } */
16 extern void abort (void);
17 const char *dont_optimize_function_away
;
19 const char *use(const char *str
)
21 dont_optimize_function_away
= str
;
24 if (str
[1] < '1' || str
[1] > '6')
28 return str
[2] ? "notused" : "v6";
31 const char *func(char *a
, char *b
)
46 for (i
= 0; i
< 2; i
++) {
47 /* bug is: following line passes wild pointer to use() on sh4 -O2 */
48 result
= use(item
[i
]);