Debian Codegraph @

gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
3 /* { dg-require-effective-target size20plus } */
4 /* { dg-additional-options "-DSKIP_STRNDUP" { target { ! strndup } } } */
5
6 #include "builtin-object-size-common.h"
7
8 typedef __SIZE_TYPE__ size_t;
9 #define abort __builtin_abort
10
11 void *
12 __attribute__ ((alloc_size (1)))
13 __attribute__ ((__nothrow__ , __leaf__))
14 __attribute__ ((noinline))
15 alloc_func_long (long sz)
16 {
17 return __builtin_malloc (sz);
18 }
19
20 void *
21 __attribute__ ((alloc_size (1)))
22 __attribute__ ((__nothrow__ , __leaf__))
23 __attribute__ ((noinline))
24 alloc_func (size_t sz)
25 {
26 return __builtin_malloc (sz);
27 }
28
29 void *
30 __attribute__ ((alloc_size (1, 2)))
31 __attribute__ ((__nothrow__ , __leaf__))
32 __attribute__ ((noinline))
33 calloc_func (size_t cnt, size_t sz)
34 {
35 return __builtin_calloc (cnt, sz);
36 }
37
38 void *
39 __attribute__ ((noinline))
40 unknown_allocator (size_t cnt, size_t sz)
41 {
42 return __builtin_calloc (cnt, sz);
43 }
44
45 size_t
46 __attribute__ ((noinline))
47 test_unknown (size_t cnt, size_t sz)
48 {
49 void *ch = unknown_allocator (cnt, sz);
50 size_t ret = __builtin_dynamic_object_size (ch, 0);
51 __builtin_free (ch);
52 return ret;
53 }
54
55 /* Malloc-like allocator. */
56
57 size_t
58 __attribute__ ((noinline))
59 test_malloc (size_t sz)
60 {
61 void *ch = alloc_func (sz);
62 size_t ret = __builtin_dynamic_object_size (ch, 0);
63 __builtin_free (ch);
64 return ret;
65 }
66
67 size_t
68 __attribute__ ((noinline))
69 test_builtin_malloc (size_t sz)
70 {
71 void *ch = __builtin_malloc (sz);
72 size_t ret = __builtin_dynamic_object_size (ch, 0);
73 __builtin_free (ch);
74 return ret;
75 }
76
77 size_t
78 __attribute__ ((noinline))
79 test_builtin_malloc_cond (int cond)
80 {
81 void *ch = __builtin_malloc (cond ? 32 : 64);
82 size_t ret = __builtin_dynamic_object_size (ch, 0);
83 __builtin_free (ch);
84 return ret;
85 }
86
87 size_t
88 __attribute__ ((noinline))
89 test_builtin_malloc_condphi (int cond)
90 {
91 void *ch;
92
93 if (cond)
94 ch = __builtin_malloc (32);
95 else
96 ch = __builtin_malloc (64);
97
98 size_t ret = __builtin_dynamic_object_size (ch, 0);
99
100 __builtin_free (ch);
101 return ret;
102 }
103
104 size_t
105 __attribute__ ((noinline))
106 test_builtin_malloc_condphi2 (int cond, size_t in)
107 {
108 void *ch;
109
110 if (cond)
111 ch = __builtin_malloc (in);
112 else
113 ch = __builtin_malloc (64);
114
115 size_t ret = __builtin_dynamic_object_size (ch, 0);
116
117 __builtin_free (ch);
118 return ret;
119 }
120
121 size_t
122 __attribute__ ((noinline))
123 test_builtin_malloc_condphi3 (int cond, size_t in, size_t in2)
124 {
125 void *ch;
126
127 if (cond)
128 ch = __builtin_malloc (in);
129 else
130 ch = __builtin_malloc (in2);
131
132 size_t ret = __builtin_dynamic_object_size (ch, 0);
133
134 __builtin_free (ch);
135 return ret;
136 }
137
138 size_t
139 __attribute__ ((noinline))
140 test_builtin_malloc_condphi4 (size_t sz, int cond)
141 {
142 char *a = __builtin_malloc (sz);
143 char b[sz / 2];
144
145 size_t ret = __builtin_dynamic_object_size (cond ? b : (void *) &a, 0);
146 __builtin_free (a);
147 return ret;
148 }
149
150 size_t
151 __attribute__ ((noinline))
152 test_builtin_malloc_condphi5 (size_t sz, int cond, char *c)
153 {
154 char *a = __builtin_malloc (sz);
155
156 size_t ret = __builtin_dynamic_object_size (cond ? c : (void *) &a, 0);
157 __builtin_free (a);
158 return ret;
159 }
160
161 long
162 __attribute__ ((noinline))
163 test_builtin_malloc_long (long sz, long off)
164 {
165 char *a = alloc_func_long (sz);
166 char *dest = a + off;
167 long ret = __builtin_dynamic_object_size (dest, 0);
168 return ret;
169 }
170
171 /* Calloc-like allocator. */
172
173 size_t
174 __attribute__ ((noinline))
175 test_calloc (size_t cnt, size_t sz)
176 {
177 void *ch = calloc_func (cnt, sz);
178 size_t ret = __builtin_dynamic_object_size (ch, 0);
179 __builtin_free (ch);
180 return ret;
181 }
182
183 size_t
184 __attribute__ ((noinline))
185 test_builtin_calloc (size_t cnt, size_t sz)
186 {
187 void *ch = __builtin_calloc (cnt, sz);
188 size_t ret = __builtin_dynamic_object_size (ch, 0);
189 __builtin_free (ch);
190 return ret;
191 }
192
193 size_t
194 __attribute__ ((noinline))
195 test_builtin_calloc_cond (int cond1, int cond2)
196 {
197 void *ch = __builtin_calloc (cond1 ? 32 : 64, cond2 ? 1024 : 16);
198 size_t ret = __builtin_dynamic_object_size (ch, 0);
199 __builtin_free (ch);
200 return ret;
201 }
202
203 size_t
204 __attribute__ ((noinline))
205 test_builtin_calloc_condphi (size_t cnt, size_t sz, int cond)
206 {
207 struct
208 {
209 int a;
210 char b;
211 } bin[cnt];
212
213 char *ch = __builtin_calloc (cnt, sz);
214 size_t ret = __builtin_dynamic_object_size (cond ? ch : (void *) &bin, 0);
215
216 __builtin_free (ch);
217 return ret;
218 }
219
220 /* Passthrough functions. */
221
222 size_t
223 __attribute__ ((noinline))
224 test_passthrough (size_t sz, char *in)
225 {
226 char *bin = __builtin_malloc (sz);
227 char *dest = __builtin_memcpy (bin, in, sz);
228
229 size_t ret = __builtin_dynamic_object_size (dest, 0);
230 __builtin_free (bin);
231 return ret;
232 }
233
234 size_t
235 __attribute__ ((noinline))
236 test_passthrough_nonssa (char *in)
237 {
238 char bin[__builtin_strlen (in) + 1];
239 char *dest = __builtin_memcpy (bin, in, __builtin_strlen (in) + 1);
240
241 return __builtin_dynamic_object_size (dest, 0);
242 }
243
244 /* Variable length arrays. */
245 size_t
246 __attribute__ ((noinline))
247 test_dynarray (size_t sz)
248 {
249 char bin[sz];
250
251 return __builtin_dynamic_object_size (bin, 0);
252 }
253
254 size_t
255 __attribute__ ((noinline))
256 test_dynarray_cond (int cond)
257 {
258 char bin[cond ? 8 : 16];
259
260 return __builtin_dynamic_object_size (bin, 0);
261 }
262
263 size_t
264 __attribute__ ((noinline))
265 test_deploop (size_t sz, size_t cond)
266 {
267 char *bin = __builtin_alloca (32);
268
269 for (size_t i = 0; i < sz; i++)
270 if (i == cond)
271 bin = __builtin_alloca (sz);
272
273 return __builtin_dynamic_object_size (bin, 0);
274 }
275
276 /* Address expressions. */
277
278 struct dynarray_struct
279 {
280 long a;
281 char c[16];
282 int b;
283 };
284
285 size_t
286 __attribute__ ((noinline))
287 test_dynarray_struct (size_t sz, size_t off)
288 {
289 struct dynarray_struct bin[sz];
290
291 return __builtin_dynamic_object_size (&bin[off].c, 0);
292 }
293
294 size_t
295 __attribute__ ((noinline))
296 test_dynarray_struct_subobj (size_t sz, size_t off)
297 {
298 struct dynarray_struct bin[sz];
299
300 return __builtin_dynamic_object_size (&bin[off].c[4], 1);
301 }
302
303 size_t
304 __attribute__ ((noinline))
305 test_dynarray_struct_subobj2 (size_t sz, size_t off, size_t *objsz)
306 {
307 struct dynarray_struct2
308 {
309 long a;
310 int b;
311 char c[sz];
312 };
313
314 struct dynarray_struct2 bin;
315
316 *objsz = sizeof (bin);
317
318 return __builtin_dynamic_object_size (&bin.c[off], 1);
319 }
320
321 /* See pr #108522. */
322
323 #define DEFSTRUCT(_s, _n) \
324 struct DS \
325 { \
326 char a[_n]; \
327 unsigned long long b; \
328 int c; \
329 char d[2 * _n]; \
330 } _s
331
332 size_t
333 __attribute__ ((noinline))
334 test_dynarray_struct_member_b (size_t sz)
335 {
336 DEFSTRUCT (s, sz);
337
338 return __builtin_dynamic_object_size (&s.b, 0);
339 }
340
341 size_t
342 __attribute__ ((noinline))
343 test_dynarray_struct_member_c (size_t sz)
344 {
345 DEFSTRUCT (s, sz);
346
347 return __builtin_dynamic_object_size (&s.c, 0);
348 }
349
350 size_t
351 __attribute__ ((noinline))
352 test_dynarray_struct_member_d (size_t sz, size_t offset)
353 {
354 DEFSTRUCT (s, sz);
355
356 return __builtin_dynamic_object_size (&s.d[offset], 0);
357 }
358
359 size_t
360 __attribute__ ((noinline))
361 test_dynarray_struct_member_subobj_b (size_t sz)
362 {
363 DEFSTRUCT (s, sz);
364
365 return __builtin_dynamic_object_size (&s.b, 1);
366 }
367
368 size_t
369 __attribute__ ((noinline))
370 test_dynarray_struct_member_subobj_c (size_t sz)
371 {
372 DEFSTRUCT (s, sz);
373
374 return __builtin_dynamic_object_size (&s.c, 1);
375 }
376
377 size_t
378 __attribute__ ((noinline))
379 test_dynarray_struct_member_subobj_d (size_t sz, size_t offset)
380 {
381 DEFSTRUCT (s, sz);
382
383 return __builtin_dynamic_object_size (&s.d[offset], 1);
384 }
385
386 size_t
387 __attribute__ ((noinline))
388 test_substring (size_t sz, size_t off)
389 {
390 char str[sz];
391
392 return __builtin_dynamic_object_size (&str[off], 0);
393 }
394
395 struct S2
396 {
397 char arr[7];
398 };
399
400 struct S1
401 {
402 int pad;
403 struct S2 s2;
404 };
405
406 static long
407 g (struct S1 *s1)
408 {
409 struct S2 *s2 = &s1->s2;
410 return __builtin_dynamic_object_size (s2->arr, 0);
411 }
412
413 long
414 __attribute__ ((noinline))
415 test_alloc_nested_structs (int x)
416 {
417 struct S1 *s1 = __builtin_malloc (x);
418 return g (s1);
419 }
420
421 /* POINTER_PLUS expressions. */
422
423 size_t
424 __attribute__ ((noinline))
425 test_substring_ptrplus (size_t sz, size_t off)
426 {
427 int str[sz];
428
429 return __builtin_dynamic_object_size (str + off, 0);
430 }
431
432 size_t
433 __attribute__ ((noinline))
434 test_substring_ptrplus2 (size_t sz, size_t off, size_t off2)
435 {
436 int str[sz];
437 int *ptr = &str[off];
438
439 return __builtin_dynamic_object_size (ptr + off2, 0);
440 }
441
442 /* Function parameters. */
443
444 size_t
445 __attribute__ ((access (__read_write__, 1, 2)))
446 __attribute__ ((noinline))
447 test_parmsz_simple (void *obj, size_t sz)
448 {
449 return __builtin_dynamic_object_size (obj, 0);
450 }
451
452 size_t
453 __attribute__ ((access (__read_write__, 2, 1)))
454 __attribute__ ((noinline))
455 test_parmsz_simple2 (size_t sz, char obj[])
456 {
457 return __builtin_dynamic_object_size (obj, 0);
458 }
459
460 size_t
461 __attribute__ ((noinline))
462 test_parmsz_simple3 (size_t sz, char obj[sz])
463 {
464 return __builtin_dynamic_object_size (obj, 0);
465 }
466
467 size_t
468 __attribute__ ((noinline))
469 __attribute__ ((access (__read_write__, 1, 2)))
470 test_parmsz (void *obj, size_t sz, size_t off)
471 {
472 return __builtin_dynamic_object_size (obj + off, 0);
473 }
474
475 size_t
476 __attribute__ ((access (__read_write__, 1, 2)))
477 __attribute__ ((noinline))
478 test_parmsz_scaled (int *obj, size_t sz)
479 {
480 return __builtin_dynamic_object_size (obj, 0);
481 }
482
483 size_t
484 __attribute__ ((noinline))
485 __attribute__ ((access (__read_write__, 1, 2)))
486 test_parmsz_scaled_off (int *obj, size_t sz, size_t off)
487 {
488 return __builtin_dynamic_object_size (obj + off, 0);
489 }
490
491 size_t
492 __attribute__ ((access (__read_write__, 1, 3)))
493 __attribute__ ((noinline))
494 test_parmsz_unknown (void *obj, void *unknown, size_t sz, int cond)
495 {
496 return __builtin_dynamic_object_size (cond ? obj : unknown, 0);
497 }
498
499 struct S;
500 size_t
501 __attribute__ ((access (__read_write__, 1, 2)))
502 __attribute__ ((noinline))
503 test_parmsz_extern (struct S *obj, size_t sz)
504 {
505 return __builtin_dynamic_object_size (obj, 0);
506 }
507
508 /* Implicitly constructed access attributes not supported yet. */
509 size_t
510 __attribute__ ((noinline))
511 test_parmsz_internal (size_t sz, double obj[][sz])
512 {
513 return __builtin_dynamic_object_size (obj, 0);
514 }
515
516 size_t
517 __attribute__ ((access (__read_write__, 2, 1)))
518 __attribute__ ((noinline))
519 test_parmsz_internal2 (size_t sz, double obj[][sz])
520 {
521 return __builtin_dynamic_object_size (obj, 0);
522 }
523
524 size_t
525 __attribute__ ((noinline))
526 test_parmsz_internal3 (size_t sz1, size_t sz2, double obj[sz1][sz2])
527 {
528 return __builtin_dynamic_object_size (obj, 0);
529 }
530
531 size_t
532 __attribute__ ((noinline))
533 test_parmsz_internal4 (size_t sz1, size_t sz2, double obj[sz1 + 1][4])
534 {
535 return __builtin_dynamic_object_size (obj, 0);
536 }
537
538 /* Loops. */
539
540 size_t
541 __attribute__ ((noinline))
542 __attribute__ ((access (__read_write__, 1, 2)))
543 test_loop (int *obj, size_t sz, size_t start, size_t end, int incr)
544 {
545 int *ptr = obj + start;
546
547 for (int i = start; i != end; i = i + incr)
548 {
549 ptr = ptr + incr;
550 if (__builtin_dynamic_object_size (ptr, 0) == 0)
551 return 0;
552 }
553
554 return __builtin_dynamic_object_size (ptr, 0);
555 }
556
557 /* strdup/strndup. */
558
559 size_t
560 __attribute__ ((noinline))
561 test_strdup (const char *in)
562 {
563 char *res = __builtin_strdup (in);
564 size_t sz = __builtin_dynamic_object_size (res, 0);
565
566 __builtin_free (res);
567 return sz;
568 }
569
570 #ifndef SKIP_STRNDUP
571 size_t
572 __attribute__ ((noinline))
573 test_strndup (const char *in, size_t bound)
574 {
575 char *res = __builtin_strndup (in, bound);
576 size_t sz = __builtin_dynamic_object_size (res, 0);
577
578 __builtin_free (res);
579 return sz;
580 }
581 #endif
582
583 size_t
584 __attribute__ ((noinline))
585 test_strdup_min (const char *in)
586 {
587 char *res = __builtin_strdup (in);
588 size_t sz = __builtin_dynamic_object_size (res, 2);
589
590 __builtin_free (res);
591 return sz;
592 }
593
594 #ifndef SKIP_STRNDUP
595 size_t
596 __attribute__ ((noinline))
597 test_strndup_min (const char *in, size_t bound)
598 {
599 char *res = __builtin_strndup (in, bound);
600 size_t sz = __builtin_dynamic_object_size (res, 2);
601
602 __builtin_free (res);
603 return sz;
604 }
605 #endif
606
607 /* Other tests. */
608
609 struct TV4
610 {
611 __attribute__((vector_size (sizeof (int) * 4))) int v;
612 };
613
614 struct TV4 val3;
615 int *
616 test_pr105736 (struct TV4 *a)
617 {
618 return &a->v[0];
619 }
620
621 int
622 main (int argc, char **argv)
623 {
624 size_t outsz = test_unknown (32, 42);
625 if (outsz != -1 && outsz != 32)
626 FAIL ();
627 if (test_malloc (2048) != 2048)
628 FAIL ();
629 if (test_builtin_malloc (2048) != 2048)
630 FAIL ();
631 if (test_builtin_malloc_cond (1) != 32)
632 FAIL ();
633 if (test_builtin_malloc_cond (0) != 64)
634 FAIL ();
635 if (test_builtin_malloc_condphi (1) != 32)
636 FAIL ();
637 if (test_builtin_malloc_condphi (0) != 64)
638 FAIL ();
639 if (test_builtin_malloc_condphi2 (1, 128) != 128)
640 FAIL ();
641 if (test_builtin_malloc_condphi2 (0, 128) != 64)
642 FAIL ();
643 if (test_builtin_malloc_condphi3 (1, 128, 256) != 128)
644 FAIL ();
645 if (test_builtin_malloc_condphi3 (0, 128, 256) != 256)
646 FAIL ();
647 if (test_builtin_malloc_condphi4 (128, 1) != 64)
648 FAIL ();
649 if (test_builtin_malloc_condphi4 (128, 0) != sizeof (void *))
650 FAIL ();
651 if (test_builtin_malloc_condphi5 (128, 0, argv[0]) != -1)
652 FAIL ();
653 long x = 42;
654 if (test_builtin_malloc_long (x, 0) != x)
655 FAIL ();
656 if (test_calloc (2048, 4) != 2048 * 4)
657 FAIL ();
658 if (test_builtin_calloc (2048, 8) != 2048 * 8)
659 FAIL ();
660 if (test_builtin_calloc_cond (0, 0) != 64 * 16)
661 FAIL ();
662 if (test_builtin_calloc_cond (1, 1) != 32 * 1024)
663 FAIL ();
664 if (test_builtin_calloc_condphi (128, 1, 0)
665 != 128 * sizeof (struct { int a; char b; }))
666 FAIL ();
667 if (test_builtin_calloc_condphi (128, 1, 1) != 128)
668 FAIL ();
669 if (test_passthrough (__builtin_strlen (argv[0]) + 1, argv[0])
670 != __builtin_strlen (argv[0]) + 1)
671 FAIL ();
672 if (test_passthrough_nonssa (argv[0]) != __builtin_strlen (argv[0]) + 1)
673 FAIL ();
674 if (test_dynarray (__builtin_strlen (argv[0])) != __builtin_strlen (argv[0]))
675 FAIL ();
676 if (test_dynarray_struct (42, 4) !=
677 ((42 - 4) * sizeof (struct dynarray_struct)
678 - __builtin_offsetof (struct dynarray_struct, c)))
679 FAIL ();
680 if (test_dynarray_struct (42, 48) != 0)
681 FAIL ();
682 if (test_substring (128, 4) != 128 - 4)
683 FAIL ();
684 if (test_substring (128, 142) != 0)
685 FAIL ();
686 if (test_dynarray_struct_subobj (42, 4) != 16 - 4)
687 FAIL ();
688 if (test_dynarray_struct_subobj (42, 48) != 0)
689 FAIL ();
690 size_t objsz = 0;
691 if (test_dynarray_struct_subobj2 (42, 4, &objsz)
692 != objsz - 4 - sizeof (long) - sizeof (int))
693 FAIL ();
694 DEFSTRUCT(ds, 64);
695 const size_t n = sizeof (ds.a);
696 if (test_dynarray_struct_member_b (n)
697 != sizeof (ds) - __builtin_offsetof (struct DS, b))
698 FAIL ();
699 if (test_dynarray_struct_member_c (n)
700 != sizeof (ds) - __builtin_offsetof (struct DS, c))
701 FAIL ();
702 if (test_dynarray_struct_member_d (n, 0)
703 != sizeof (ds) - __builtin_offsetof (struct DS, d))
704 FAIL ();
705 if (test_dynarray_struct_member_subobj_b (n) != sizeof (ds.b))
706 FAIL ();
707 if (test_dynarray_struct_member_subobj_c (n) != sizeof (ds.c))
708 FAIL ();
709 if (test_dynarray_struct_member_subobj_d (n, n - 2)
710 != sizeof (ds) - __builtin_offsetof (struct DS, d) - n + 2)
711 FAIL ();
712 if (test_substring_ptrplus (128, 4) != (128 - 4) * sizeof (int))
713 FAIL ();
714 if (test_substring_ptrplus (128, 142) != 0)
715 FAIL ();
716 if (test_substring_ptrplus2 (128, 4, 4) != (128 - 8) * sizeof (int))
717 FAIL ();
718 if (test_substring_ptrplus2 (128, 4, -3) != (128 - 1) * sizeof (int))
719 FAIL ();
720 if (test_dynarray_cond (0) != 16)
721 FAIL ();
722 if (test_dynarray_cond (1) != 8)
723 FAIL ();
724 if (test_alloc_nested_structs (42) != 42 - sizeof (int))
725 FAIL ();
726 if (test_deploop (128, 4) != 128)
727 FAIL ();
728 if (test_deploop (128, 129) != 32)
729 FAIL ();
730 if (test_parmsz_simple (argv[0], __builtin_strlen (argv[0]) + 1)
731 != __builtin_strlen (argv[0]) + 1)
732 FAIL ();
733 if (test_parmsz_simple2 (__builtin_strlen (argv[0]) + 1, argv[0])
734 != __builtin_strlen (argv[0]) + 1)
735 FAIL ();
736 if (test_parmsz_simple3 (__builtin_strlen (argv[0]) + 1, argv[0])
737 != __builtin_strlen (argv[0]) + 1)
738 FAIL ();
739 int arr[42];
740 if (test_parmsz_scaled (arr, 42) != sizeof (arr))
741 FAIL ();
742 if (test_parmsz_scaled (arr, 40) != 40 * sizeof (int))
743 FAIL ();
744 /* __bdos cannot see the actual size of ARR, so it will return what it was
745 passed. Fortunately though the overflow warnings see this caller side and
746 warns of the problematic size. */
747 if (test_parmsz_scaled (arr, 44) != 44 * sizeof (int)) /* { dg-warning "-Wstringop-overflow=" } */
748 FAIL ();
749 if (test_parmsz_unknown (argv[0], argv[0], __builtin_strlen (argv[0]) + 1, 0)
750 != -1)
751 if (test_parmsz (argv[0], __builtin_strlen (argv[0]) + 1, -1) != 0)
752 FAIL ();
753 if (test_parmsz (argv[0], __builtin_strlen (argv[0]) + 1, 0)
754 != __builtin_strlen (argv[0]) + 1)
755 FAIL ();
756 if (test_parmsz (argv[0], __builtin_strlen (argv[0]) + 1,
757 __builtin_strlen (argv[0])) != 1)
758 FAIL ();
759 if (test_parmsz (argv[0], __builtin_strlen (argv[0]) + 1,
760 __builtin_strlen (argv[0]) + 2) != 0)
761 FAIL ();
762 if (test_parmsz_scaled_off (arr, 42, 2) != 40 * sizeof (int))
763 FAIL ();
764 struct S *s;
765 if (test_parmsz_extern (s, 42) != -1)
766 FAIL ();
767 double obj[4][4];
768 if (test_parmsz_internal (4, obj) != -1)
769 FAIL ();
770 if (test_parmsz_internal2 (4, obj) != -1)
771 FAIL ();
772 if (test_parmsz_internal3 (4, 4, obj) != -1)
773 FAIL ();
774 if (test_parmsz_internal4 (3, 4, obj) != -1)
775 FAIL ();
776 if (test_loop (arr, 42, 0, 32, 1) != 10 * sizeof (int))
777 FAIL ();
778 if (test_loop (arr, 42, 32, -1, -1) != 0)
779 FAIL ();
780 if (test_loop (arr, 42, 32, 10, -1) != 32 * sizeof (int))
781 FAIL ();
782 if (test_loop (arr, 42, 42, 0, -1) != 42 * sizeof (int))
783 FAIL ();
784 if (test_loop (arr, 42, 44, 0, -1) != 0)
785 FAIL ();
786 if (test_loop (arr, 42, 20, 52, 1) != 0)
787 FAIL ();
788 /* pr105736. */
789 int *t = test_pr105736 (&val3);
790 if (__builtin_dynamic_object_size (t, 0) != -1)
791 FAIL ();
792 const char *str = "hello world";
793 if (test_strdup (str) != __builtin_strlen (str) + 1)
794 FAIL ();
795 #ifndef SKIP_STRNDUP
796 if (test_strndup (str, 4) != 5)
797 FAIL ();
798 #endif
799 if (test_strdup_min (str) != __builtin_strlen (str) + 1)
800 FAIL ();
801 #ifndef SKIP_STRNDUP
802 if (test_strndup_min (str, 4) != 1)
803 FAIL ();
804 #endif
805
806 DONE ();
807 }