Disable tests for strdup/strndup on __hpux__
[official-gcc.git] / gcc / testsuite / gcc.dg / builtin-object-size-1.c
blob4f7d4c0b370f592b2183926e2e5e73d427ba58c9
1 /* { dg-do run } */
2 /* { dg-options "-O2 -Wno-stringop-overread" } */
3 /* { dg-require-effective-target alloca } */
5 #include "builtin-object-size-common.h"
7 struct A
9 char a[10];
10 int b;
11 char c[10];
12 } y, w[4];
14 extern char exta[];
15 extern char extb[30];
16 extern struct A zerol[0];
18 void
19 __attribute__ ((noinline))
20 test1 (void *q, int x)
22 struct A a;
23 void *p = &a.a[3], *r;
24 char var[x + 10];
25 if (x < 0)
26 r = &a.a[9];
27 else
28 r = &a.c[1];
29 if (__builtin_object_size (p, 0)
30 != sizeof (a) - __builtin_offsetof (struct A, a) - 3)
31 FAIL ();
32 if (__builtin_object_size (&a.c[9], 0)
33 != sizeof (a) - __builtin_offsetof (struct A, c) - 9)
34 FAIL ();
35 if (__builtin_object_size (q, 0) != (size_t) -1)
36 FAIL ();
37 #ifdef __builtin_object_size
38 if (__builtin_object_size (r, 0)
39 != (x < 0
40 ? sizeof (a) - __builtin_offsetof (struct A, a) - 9
41 : sizeof (a) - __builtin_offsetof (struct A, c) - 1))
42 FAIL ();
43 #else
44 if (__builtin_object_size (r, 0)
45 != sizeof (a) - __builtin_offsetof (struct A, a) - 9)
46 FAIL ();
47 #endif
48 if (x < 6)
49 r = &w[2].a[1];
50 else
51 r = &a.a[6];
52 if (__builtin_object_size (&y, 0)
53 != sizeof (y))
54 FAIL ();
55 if (__builtin_object_size (w, 0)
56 != sizeof (w))
57 FAIL ();
58 if (__builtin_object_size (&y.b, 0)
59 != sizeof (a) - __builtin_offsetof (struct A, b))
60 FAIL ();
61 #ifdef __builtin_object_size
62 if (__builtin_object_size (r, 0)
63 != (x < 6
64 ? 2 * sizeof (w[0]) - __builtin_offsetof (struct A, a) - 1
65 : sizeof (a) - __builtin_offsetof (struct A, a) - 6))
66 FAIL ();
67 #else
68 if (__builtin_object_size (r, 0)
69 != 2 * sizeof (w[0]) - __builtin_offsetof (struct A, a) - 1)
70 FAIL ();
71 #endif
72 if (x < 20)
73 r = malloc (30);
74 else
75 r = calloc (2, 16);
76 #ifdef __builtin_object_size
77 if (__builtin_object_size (r, 0) != (x < 20 ? 30 : 2 * 16))
78 FAIL ();
79 #else
80 /* We may duplicate this test onto the two exit paths. On one path
81 the size will be 32, the other it will be 30. If we don't duplicate
82 this test, then the size will be 32. */
83 if (__builtin_object_size (r, 0) != 2 * 16
84 && __builtin_object_size (r, 0) != 30)
85 FAIL ();
86 #endif
87 if (x < 20)
88 r = malloc (30);
89 else
90 r = calloc (2, 14);
91 #ifdef __builtin_object_size
92 if (__builtin_object_size (r, 0) != (x < 20 ? 30 : 2 * 14))
93 FAIL ();
94 #else
95 if (__builtin_object_size (r, 0) != 30)
96 FAIL ();
97 #endif
98 if (x < 30)
99 r = malloc (sizeof (a));
100 else
101 r = &a.a[3];
102 #ifdef __builtin_object_size
103 if (__builtin_object_size (r, 0) != (x < 30 ? sizeof (a) : sizeof (a) - 3))
104 FAIL ();
105 #else
106 if (__builtin_object_size (r, 0) != sizeof (a))
107 FAIL ();
108 #endif
109 r = memcpy (r, "a", 2);
110 #ifdef __builtin_object_size
111 if (__builtin_object_size (r, 0) != (x < 30 ? sizeof (a) : sizeof (a) - 3))
112 FAIL ();
113 #else
114 if (__builtin_object_size (r, 0) != sizeof (a))
115 FAIL ();
116 #endif
117 r = memcpy (r + 2, "b", 2) + 2;
118 #ifdef __builtin_object_size
119 if (__builtin_object_size (r, 0)
120 != (x < 30 ? sizeof (a) - 4 : sizeof (a) - 7))
121 FAIL ();
122 #else
123 if (__builtin_object_size (r, 0) != sizeof (a) - 4)
124 FAIL ();
125 #endif
126 r = &a.a[4];
127 r = memset (r, 'a', 2);
128 if (__builtin_object_size (r, 0)
129 != sizeof (a) - __builtin_offsetof (struct A, a) - 4)
130 FAIL ();
131 r = memset (r + 2, 'b', 2) + 2;
132 if (__builtin_object_size (r, 0)
133 != sizeof (a) - __builtin_offsetof (struct A, a) - 8)
134 FAIL ();
135 r = &a.a[1];
136 r = strcpy (r, "ab");
137 if (__builtin_object_size (r, 0)
138 != sizeof (a) - __builtin_offsetof (struct A, a) - 1)
139 FAIL ();
140 r = strcpy (r + 2, "cd") + 2;
141 if (__builtin_object_size (r, 0)
142 != sizeof (a) - __builtin_offsetof (struct A, a) - 5)
143 FAIL ();
144 if (__builtin_object_size (exta, 0) != (size_t) -1)
145 FAIL ();
146 if (__builtin_object_size (exta + 10, 0) != (size_t) -1)
147 FAIL ();
148 if (__builtin_object_size (&exta[5], 0) != (size_t) -1)
149 FAIL ();
150 if (__builtin_object_size (extb, 0) != sizeof (extb))
151 FAIL ();
152 if (__builtin_object_size (extb + 10, 0) != sizeof (extb) - 10)
153 FAIL ();
154 if (__builtin_object_size (&extb[5], 0) != sizeof (extb) - 5)
155 FAIL ();
156 #ifdef __builtin_object_size
157 if (__builtin_object_size (var, 0) != x + 10)
158 FAIL ();
159 if (__builtin_object_size (var + 10, 0) != x)
160 FAIL ();
161 if (__builtin_object_size (&var[5], 0) != x + 5)
162 FAIL ();
163 #else
164 if (__builtin_object_size (var, 0) != (size_t) -1)
165 FAIL ();
166 if (__builtin_object_size (var + 10, 0) != (size_t) -1)
167 FAIL ();
168 if (__builtin_object_size (&var[5], 0) != (size_t) -1)
169 FAIL ();
170 #endif
171 if (__builtin_object_size (zerol, 0) != 0)
172 FAIL ();
173 if (__builtin_object_size (&zerol, 0) != 0)
174 FAIL ();
175 if (__builtin_object_size (&zerol[0], 0) != 0)
176 FAIL ();
177 if (__builtin_object_size (zerol[0].a, 0) != 0)
178 FAIL ();
179 if (__builtin_object_size (&zerol[0].a[0], 0) != 0)
180 FAIL ();
181 if (__builtin_object_size (&zerol[0].b, 0) != 0)
182 FAIL ();
183 if (__builtin_object_size ("abcdefg", 0) != sizeof ("abcdefg"))
184 FAIL ();
185 if (__builtin_object_size ("abcd\0efg", 0) != sizeof ("abcd\0efg"))
186 FAIL ();
187 if (__builtin_object_size (&"abcd\0efg", 0) != sizeof ("abcd\0efg"))
188 FAIL ();
189 if (__builtin_object_size (&"abcd\0efg"[0], 0) != sizeof ("abcd\0efg"))
190 FAIL ();
191 if (__builtin_object_size (&"abcd\0efg"[4], 0) != sizeof ("abcd\0efg") - 4)
192 FAIL ();
193 if (__builtin_object_size ("abcd\0efg" + 5, 0) != sizeof ("abcd\0efg") - 5)
194 FAIL ();
195 if (__builtin_object_size (L"abcdefg", 0) != sizeof (L"abcdefg"))
196 FAIL ();
197 r = (char *) L"abcd\0efg";
198 if (__builtin_object_size (r + 2, 0) != sizeof (L"abcd\0efg") - 2)
199 FAIL ();
202 size_t l1 = 1;
204 void
205 __attribute__ ((noinline))
206 test2 (void)
208 struct B { char buf1[10]; char buf2[10]; } a;
209 char *r, buf3[20];
210 int i;
211 size_t res;
213 if (sizeof (a) != 20)
214 return;
216 r = buf3;
217 for (i = 0; i < 4; ++i)
219 if (i == l1 - 1)
220 r = &a.buf1[1];
221 else if (i == l1)
222 r = &a.buf2[7];
223 else if (i == l1 + 1)
224 r = &buf3[5];
225 else if (i == l1 + 2)
226 r = &a.buf1[9];
228 #ifdef __builtin_object_size
229 res = sizeof (buf3);
231 for (i = 0; i < 4; ++i)
233 if (i == l1 - 1)
234 res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 1;
235 else if (i == l1)
236 res = sizeof (a) - __builtin_offsetof (struct B, buf2) - 7;
237 else if (i == l1 + 1)
238 res = sizeof (buf3) - 5;
239 else if (i == l1 + 2)
240 res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9;
242 #else
243 res = 20;
244 #endif
245 if (__builtin_object_size (r, 0) != res)
246 FAIL ();
247 r = &buf3[20];
248 for (i = 0; i < 4; ++i)
250 if (i == l1 - 1)
251 r = &a.buf1[7];
252 else if (i == l1)
253 r = &a.buf2[7];
254 else if (i == l1 + 1)
255 r = &buf3[5];
256 else if (i == l1 + 2)
257 r = &a.buf1[9];
259 #ifdef __builtin_object_size
260 res = sizeof (buf3) - 20;
262 for (i = 0; i < 4; ++i)
264 if (i == l1 - 1)
265 res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 7;
266 else if (i == l1)
267 res = sizeof (a) - __builtin_offsetof (struct B, buf2) - 7;
268 else if (i == l1 + 1)
269 res = sizeof (buf3) - 5;
270 else if (i == l1 + 2)
271 res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9;
273 if (__builtin_object_size (r, 0) != res)
274 FAIL ();
275 #else
276 res = 15;
277 #endif
278 if (__builtin_object_size (r, 0) != res)
279 FAIL ();
280 r += 8;
281 #ifdef __builtin_object_size
282 res -= 8;
283 if (__builtin_object_size (r, 0) != res)
284 FAIL ();
285 if (res >= 6)
287 if (__builtin_object_size (r + 6, 0) != res - 6)
288 FAIL ();
290 else if (__builtin_object_size (r + 6, 0) != 0)
291 FAIL ();
292 #else
293 if (__builtin_object_size (r, 0) != 7)
294 FAIL ();
295 if (__builtin_object_size (r + 6, 0) != 1)
296 FAIL ();
297 #endif
298 r = &buf3[18];
299 for (i = 0; i < 4; ++i)
301 if (i == l1 - 1)
302 r = &a.buf1[9];
303 else if (i == l1)
304 r = &a.buf2[9];
305 else if (i == l1 + 1)
306 r = &buf3[5];
307 else if (i == l1 + 2)
308 r = &a.buf1[4];
310 #ifdef __builtin_object_size
311 res = sizeof (buf3) - 18;
313 for (i = 0; i < 4; ++i)
315 if (i == l1 - 1)
316 res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 9;
317 else if (i == l1)
318 res = sizeof (a) - __builtin_offsetof (struct B, buf2) - 9;
319 else if (i == l1 + 1)
320 res = sizeof (buf3) - 5;
321 else if (i == l1 + 2)
322 res = sizeof (a) - __builtin_offsetof (struct B, buf1) - 4;
324 if (res >= 12)
326 if (__builtin_object_size (r + 12, 0) != res - 12)
327 FAIL ();
329 else if (__builtin_object_size (r + 12, 0) != 0)
330 FAIL ();
331 #else
332 if (__builtin_object_size (r + 12, 0) != 4)
333 FAIL ();
334 #endif
337 void
338 __attribute__ ((noinline))
339 test3 (void)
341 char buf4[10];
342 struct B { struct A a[2]; struct A b; char c[4]; char d; double e;
343 _Complex double f; } x;
344 double y;
345 _Complex double z;
346 double *dp;
348 if (__builtin_object_size (buf4, 0) != sizeof (buf4))
349 FAIL ();
350 if (__builtin_object_size (&buf4, 0) != sizeof (buf4))
351 FAIL ();
352 if (__builtin_object_size (&buf4[0], 0) != sizeof (buf4))
353 FAIL ();
354 if (__builtin_object_size (&buf4[1], 0) != sizeof (buf4) - 1)
355 FAIL ();
356 if (__builtin_object_size (&x, 0) != sizeof (x))
357 FAIL ();
358 if (__builtin_object_size (&x.a, 0) != sizeof (x))
359 FAIL ();
360 if (__builtin_object_size (&x.a[0], 0) != sizeof (x))
361 FAIL ();
362 if (__builtin_object_size (&x.a[0].a, 0) != sizeof (x))
363 FAIL ();
364 if (__builtin_object_size (&x.a[0].a[0], 0) != sizeof (x))
365 FAIL ();
366 if (__builtin_object_size (&x.a[0].a[3], 0) != sizeof (x) - 3)
367 FAIL ();
368 if (__builtin_object_size (&x.a[0].b, 0)
369 != sizeof (x) - __builtin_offsetof (struct A, b))
370 FAIL ();
371 if (__builtin_object_size (&x.a[1].c, 0)
372 != sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c))
373 FAIL ();
374 if (__builtin_object_size (&x.a[1].c[0], 0)
375 != sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c))
376 FAIL ();
377 if (__builtin_object_size (&x.a[1].c[3], 0)
378 != sizeof (x) - sizeof (struct A) - __builtin_offsetof (struct A, c) - 3)
379 FAIL ();
380 if (__builtin_object_size (&x.b, 0)
381 != sizeof (x) - __builtin_offsetof (struct B, b))
382 FAIL ();
383 if (__builtin_object_size (&x.b.a, 0)
384 != sizeof (x) - __builtin_offsetof (struct B, b))
385 FAIL ();
386 if (__builtin_object_size (&x.b.a[0], 0)
387 != sizeof (x) - __builtin_offsetof (struct B, b))
388 FAIL ();
389 if (__builtin_object_size (&x.b.a[3], 0)
390 != sizeof (x) - __builtin_offsetof (struct B, b) - 3)
391 FAIL ();
392 if (__builtin_object_size (&x.b.b, 0)
393 != sizeof (x) - __builtin_offsetof (struct B, b)
394 - __builtin_offsetof (struct A, b))
395 FAIL ();
396 if (__builtin_object_size (&x.b.c, 0)
397 != sizeof (x) - __builtin_offsetof (struct B, b)
398 - __builtin_offsetof (struct A, c))
399 FAIL ();
400 if (__builtin_object_size (&x.b.c[0], 0)
401 != sizeof (x) - __builtin_offsetof (struct B, b)
402 - __builtin_offsetof (struct A, c))
403 FAIL ();
404 if (__builtin_object_size (&x.b.c[3], 0)
405 != sizeof (x) - __builtin_offsetof (struct B, b)
406 - __builtin_offsetof (struct A, c) - 3)
407 FAIL ();
408 if (__builtin_object_size (&x.c, 0)
409 != sizeof (x) - __builtin_offsetof (struct B, c))
410 FAIL ();
411 if (__builtin_object_size (&x.c[0], 0)
412 != sizeof (x) - __builtin_offsetof (struct B, c))
413 FAIL ();
414 if (__builtin_object_size (&x.c[1], 0)
415 != sizeof (x) - __builtin_offsetof (struct B, c) - 1)
416 FAIL ();
417 if (__builtin_object_size (&x.d, 0)
418 != sizeof (x) - __builtin_offsetof (struct B, d))
419 FAIL ();
420 if (__builtin_object_size (&x.e, 0)
421 != sizeof (x) - __builtin_offsetof (struct B, e))
422 FAIL ();
423 if (__builtin_object_size (&x.f, 0)
424 != sizeof (x) - __builtin_offsetof (struct B, f))
425 FAIL ();
426 dp = &__real__ x.f;
427 if (__builtin_object_size (dp, 0)
428 != sizeof (x) - __builtin_offsetof (struct B, f))
429 FAIL ();
430 dp = &__imag__ x.f;
431 if (__builtin_object_size (dp, 0)
432 != sizeof (x) - __builtin_offsetof (struct B, f)
433 - sizeof (x.f) / 2)
434 FAIL ();
435 dp = &y;
436 if (__builtin_object_size (dp, 0) != sizeof (y))
437 FAIL ();
438 if (__builtin_object_size (&z, 0) != sizeof (z))
439 FAIL ();
440 dp = &__real__ z;
441 if (__builtin_object_size (dp, 0) != sizeof (z))
442 FAIL ();
443 dp = &__imag__ z;
444 if (__builtin_object_size (dp, 0) != sizeof (z) / 2)
445 FAIL ();
448 struct S { unsigned int a; };
450 char *
451 __attribute__ ((noinline))
452 test4 (char *x, int y)
454 register int i;
455 struct A *p;
457 for (i = 0; i < y; i++)
459 p = (struct A *) x;
460 x = (char *) &p[1];
461 if (__builtin_object_size (p, 0) != (size_t) -1)
462 FAIL ();
464 return x;
467 void
468 __attribute__ ((noinline))
469 test5 (size_t x)
471 char buf[64];
472 char *p = &buf[8];
473 size_t i;
475 for (i = 0; i < x; ++i)
476 p = p + 4;
477 #ifdef __builtin_object_size
478 if (__builtin_object_size (p, 0) != sizeof (buf) - 8 - 4 * x)
479 FAIL ();
480 #else
481 /* My understanding of ISO C99 6.5.6 is that a conforming
482 program will not end up with p equal to &buf[0]
483 through &buf[7], i.e. calling this function with say
484 UINTPTR_MAX / 4 results in undefined behavior.
485 If that's true, then the maximum number of remaining
486 bytes from p until end of the object is 56, otherwise
487 it would be 64 (or conservative (size_t) -1 == unknown). */
488 if (__builtin_object_size (p, 0) != sizeof (buf) - 8)
489 FAIL ();
490 #endif
491 memset (p, ' ', sizeof (buf) - 8 - 4 * 4);
494 void
495 __attribute__ ((noinline))
496 test6 (size_t x)
498 struct T { char buf[64]; char buf2[64]; } t;
499 char *p = &t.buf[8];
500 size_t i;
502 for (i = 0; i < x; ++i)
503 p = p + 4;
504 #ifdef __builtin_object_size
505 if (__builtin_object_size (p, 0) != sizeof (t) - 8 - 4 * x)
506 FAIL ();
507 #else
508 if (__builtin_object_size (p, 0) != sizeof (t) - 8)
509 FAIL ();
510 #endif
511 memset (p, ' ', sizeof (t) - 8 - 4 * 4);
514 void
515 __attribute__ ((noinline))
516 test7 (void)
518 char buf[64];
519 struct T { char buf[64]; char buf2[64]; } t;
520 char *p = &buf[64], *q = &t.buf[64];
522 if (__builtin_object_size (p + 64, 0) != 0)
523 FAIL ();
524 if (__builtin_object_size (q + 63, 0) != sizeof (t) - 64 - 63)
525 FAIL ();
526 if (__builtin_object_size (q + 64, 0) != sizeof (t) - 64 - 64)
527 FAIL ();
528 if (__builtin_object_size (q + 256, 0) != 0)
529 FAIL ();
532 void
533 __attribute__ ((noinline))
534 test8 (void)
536 struct T { char buf[10]; char buf2[10]; } t;
537 char *p = &t.buf2[-4];
538 char *q = &t.buf2[0];
539 if (__builtin_object_size (p, 0) != sizeof (t) - 10 + 4)
540 FAIL ();
541 if (__builtin_object_size (q, 0) != sizeof (t) - 10)
542 FAIL ();
543 /* GCC only handles additions, not subtractions. */
544 q = q - 8;
545 if (__builtin_object_size (q, 0) != (size_t) -1
546 && __builtin_object_size (q, 0) != sizeof (t) - 10 + 8)
547 FAIL ();
548 p = &t.buf[-4];
549 if (__builtin_object_size (p, 0) != 0)
550 FAIL ();
553 void
554 __attribute__ ((noinline))
555 test9 (unsigned cond)
557 char *buf2 = malloc (10);
558 char *p;
560 if (cond)
561 p = &buf2[8];
562 else
563 p = &buf2[4];
565 #ifdef __builtin_object_size
566 if (__builtin_object_size (&p[-4], 0) != (cond ? 6 : 10))
567 FAIL ();
568 #else
569 if (__builtin_object_size (&p[-4], 0) != 10)
570 FAIL ();
571 #endif
573 for (unsigned i = cond; i > 0; i--)
574 p--;
576 #ifdef __builtin_object_size
577 if (__builtin_object_size (p, 0) != ((cond ? 2 : 6) + cond))
578 FAIL ();
579 #else
580 if (__builtin_object_size (p, 0) != 10)
581 FAIL ();
582 #endif
584 p = &y.c[8];
585 for (unsigned i = cond; i > 0; i--)
586 p--;
588 #ifdef __builtin_object_size
589 if (__builtin_object_size (p, 0)
590 != sizeof (y) - __builtin_offsetof (struct A, c) - 8 + cond)
591 FAIL ();
592 #else
593 if (__builtin_object_size (p, 0) != sizeof (y))
594 FAIL ();
595 #endif
598 void
599 __attribute__ ((noinline))
600 test10 (void)
602 static char buf[255];
603 unsigned int i, len = sizeof (buf);
604 char *p = buf;
606 for (i = 0 ; i < sizeof (buf) ; i++)
608 if (len < 2)
610 #ifdef __builtin_object_size
611 if (__builtin_object_size (p - 3, 0) != sizeof (buf) - i + 3)
612 FAIL ();
613 #else
614 if (__builtin_object_size (p - 3, 0) != sizeof (buf))
615 FAIL ();
616 #endif
617 break;
619 p++;
620 len--;
624 #if !defined(__AVR__) && !defined(__hpux__) /* avr and hpux have no strndup */
625 /* Tests for strdup/strndup. */
626 size_t
627 __attribute__ ((noinline))
628 test11 (void)
630 int i = 0;
631 const char *ptr = "abcdefghijklmnopqrstuvwxyz";
632 char *res = strndup (ptr, 21);
633 if (__builtin_object_size (res, 0) != 22)
634 FAIL ();
636 free (res);
638 res = strndup (ptr, 32);
639 if (__builtin_object_size (res, 0) != 27)
640 FAIL ();
642 free (res);
644 res = strdup (ptr);
645 if (__builtin_object_size (res, 0) != 27)
646 FAIL ();
648 free (res);
650 char *ptr2 = malloc (64);
651 strcpy (ptr2, ptr);
653 res = strndup (ptr2, 21);
654 if (__builtin_object_size (res, 0) != 22)
655 FAIL ();
657 free (res);
659 res = strndup (ptr2, 32);
660 if (__builtin_object_size (res, 0) != 33)
661 FAIL ();
663 free (res);
665 res = strndup (ptr2, 128);
666 if (__builtin_object_size (res, 0) != 64)
667 FAIL ();
669 free (res);
671 res = strdup (ptr2);
672 #ifdef __builtin_object_size
673 if (__builtin_object_size (res, 0) != 27)
674 #else
675 if (__builtin_object_size (res, 0) != (size_t) -1)
676 #endif
677 FAIL ();
678 free (res);
679 free (ptr2);
681 ptr = "abcd\0efghijklmnopqrstuvwxyz";
682 res = strdup (ptr);
683 if (__builtin_object_size (res, 0) != 5)
684 FAIL ();
685 free (res);
687 res = strndup (ptr, 24);
688 if (__builtin_object_size (res, 0) != 5)
689 FAIL ();
690 free (res);
692 res = strndup (ptr, 2);
693 if (__builtin_object_size (res, 0) != 3)
694 FAIL ();
695 free (res);
697 res = strdup (&ptr[4]);
698 if (__builtin_object_size (res, 0) != 1)
699 FAIL ();
700 free (res);
702 res = strndup (&ptr[4], 4);
703 if (__builtin_object_size (res, 0) != 1)
704 FAIL ();
705 free (res);
707 res = strndup (&ptr[4], 1);
708 if (__builtin_object_size (res, 0) != 1)
709 FAIL ();
710 free (res);
712 #endif /* avr */
715 main (void)
717 struct S s[10];
718 __asm ("" : "=r" (l1) : "0" (l1));
719 test1 (main, 6);
720 test2 ();
721 test3 ();
722 test4 ((char *) s, 10);
723 test5 (4);
724 test6 (4);
725 test7 ();
726 test8 ();
727 test9 (1);
728 test10 ();
729 #if !defined(__AVR__) && !defined(__hpux__) /* avr and hpux have no strndup */
730 test11 ();
731 #endif
732 DONE ();