2 strlen-3.c from the execute part of the gcc torture tests.
9 /* PR tree-optimization/86532 - Wrong code due to a wrong strlen folding
11 Exercise strlen() with a multi-dimensional array of strings with
14 extern size_t strlen (const char*);
16 static const char a
[2][3][9] = {
18 { "12\0003", "123\0004" }
30 void test_array_ref (void)
41 ASSERT (strlen (a
[0][0]) == 1);
42 ASSERT (strlen (a
[0][1]) == 1);
44 ASSERT (strlen (a
[1][0]) == 2);
45 ASSERT (strlen (a
[1][1]) == 3);
47 ASSERT (strlen (&a
[0][0][0]) == 1);
48 ASSERT (strlen (&a
[0][1][0]) == 1);
50 ASSERT (strlen (&a
[1][0][0]) == 2);
51 ASSERT (strlen (&a
[1][1][0]) == 3);
53 ASSERT (strlen (&a
[0][0][0] + 1) == 0);
54 ASSERT (strlen (&a
[0][1][0] + 1) == 0);
55 ASSERT (strlen (&a
[0][1][0] + 2) == 1);
56 ASSERT (strlen (&a
[0][1][0] + 3) == 0);
57 ASSERT (strlen (&a
[0][1][0] + 7) == 0);
59 ASSERT (strlen (&a
[1][0][0] + 1) == 1);
60 ASSERT (strlen (&a
[1][1][0] + 1) == 2);
61 ASSERT (strlen (&a
[1][1][0] + 2) == 1);
62 ASSERT (strlen (&a
[1][1][0] + 7) == 0);
64 #if !defined(__SDCC_pdk13) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of code memory
65 ASSERT (strlen (a
[i0
][i0
]) == 1);
66 ASSERT (strlen (a
[i0
][i1
]) == 1);
68 ASSERT (strlen (a
[i1
][i0
]) == 2);
69 ASSERT (strlen (a
[i1
][i1
]) == 3);
71 ASSERT (strlen (&a
[i0
][i0
][i0
]) == 1);
72 ASSERT (strlen (&a
[i0
][i1
][i0
]) == 1);
73 ASSERT (strlen (&a
[i0
][i1
][i1
]) == 0);
74 ASSERT (strlen (&a
[i0
][i1
][i2
]) == 1);
75 ASSERT (strlen (&a
[i0
][i1
][i3
]) == 0);
76 ASSERT (strlen (&a
[i0
][i1
][i3
]) == 0);
78 ASSERT (strlen (&a
[i1
][i0
][i0
]) == 2);
79 ASSERT (strlen (&a
[i1
][i1
][i0
]) == 3);
80 ASSERT (strlen (&a
[i1
][i1
][i1
]) == 2);
81 ASSERT (strlen (&a
[i1
][i1
][i2
]) == 1);
82 ASSERT (strlen (&a
[i1
][i1
][i3
]) == 0);
83 ASSERT (strlen (&a
[i1
][i1
][i4
]) == 1);
84 ASSERT (strlen (&a
[i1
][i1
][i5
]) == 0);
85 ASSERT (strlen (&a
[i1
][i1
][i6
]) == 0);
86 ASSERT (strlen (&a
[i1
][i1
][i7
]) == 0);
88 ASSERT (strlen (&a
[i0
][i0
][i0
] + i1
) == 0);
89 ASSERT (strlen (&a
[i0
][i1
][i0
] + i1
) == 0);
90 ASSERT (strlen (&a
[i0
][i1
][i0
] + i7
) == 0);
92 ASSERT (strlen (&a
[i1
][i0
][i0
] + i1
) == 1);
93 ASSERT (strlen (&a
[i1
][i1
][i0
] + i1
) == 2);
94 ASSERT (strlen (&a
[i1
][i1
][i0
] + i2
) == 1);
95 ASSERT (strlen (&a
[i1
][i1
][i0
] + i3
) == 0);
96 ASSERT (strlen (&a
[i1
][i1
][i0
] + i4
) == 1);
97 ASSERT (strlen (&a
[i1
][i1
][i0
] + i5
) == 0);
98 ASSERT (strlen (&a
[i1
][i1
][i0
] + i6
) == 0);
99 ASSERT (strlen (&a
[i1
][i1
][i0
] + i7
) == 0);
102 ASSERT (strlen (a
[i0
][i0
]) == 1);
103 ASSERT (strlen (a
[i0
][i1
]) == 1);
105 ASSERT (strlen (a
[i1
][i0
]) == 2);
106 ASSERT (strlen (a
[i1
][i1
]) == 3);
108 ASSERT (strlen (&a
[i0
][i0
][i0
]) == 1);
109 ASSERT (strlen (&a
[i0
][i1
][i0
]) == 1);
111 ASSERT (strlen (&a
[i1
][i0
][i0
]) == 2);
112 ASSERT (strlen (&a
[i1
][i1
][i0
]) == 3);
114 ASSERT (strlen (&a
[i0
][i0
][i0
] + v1
) == 0);
115 ASSERT (strlen (&a
[i0
][i0
][i0
] + v2
) == 0);
116 ASSERT (strlen (&a
[i0
][i0
][i0
] + v7
) == 0);
118 ASSERT (strlen (&a
[i0
][i1
][i0
] + v1
) == 0);
119 ASSERT (strlen (&a
[i0
][i1
][i0
] + v2
) == 1);
120 ASSERT (strlen (&a
[i0
][i1
][i0
] + v3
) == 0);
122 ASSERT (strlen (&a
[i1
][i0
][i0
] + v1
) == 1);
123 ASSERT (strlen (&a
[i1
][i1
][i0
] + v1
) == 2);
124 ASSERT (strlen (&a
[i1
][i1
][i0
] + v2
) == 1);
125 ASSERT (strlen (&a
[i1
][i1
][i0
] + v3
) == 0);
126 ASSERT (strlen (&a
[i1
][i1
][i0
] + v4
) == 1);
127 ASSERT (strlen (&a
[i1
][i1
][i0
] + v5
) == 0);
128 ASSERT (strlen (&a
[i1
][i1
][i0
] + v6
) == 0);
129 ASSERT (strlen (&a
[i1
][i1
][i0
] + v7
) == 0);
134 testTortureExecute (void)