comparison gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* { dg-do compile } */
2 /* { dg-options "-fcilkplus" } */
3
4 /* This test has no array notation components in it and thus should compile
5 fine without crashing. */
6
7 typedef unsigned int size_t;
8 typedef int (*__compar_fn_t) (const void *, const void *);
9 extern void *bsearch (const void *__key, const void *__base,
10 size_t __nmemb, size_t __size, __compar_fn_t
11 __compar)
12 __attribute__ ((__nonnull__ (1, 2, 5))) ;
13 extern __inline __attribute__ ((__gnu_inline__)) void *
14 bsearch (const void *__key, const void *__base, size_t __nmemb, size_t
15 __size,
16 __compar_fn_t __compar)
17 {
18 size_t __l, __u, __idx;
19 const void *__p;
20 int __comparison;
21 __l = 0;
22 __u = __nmemb;
23 while (__l < __u)
24 {
25 __idx = (__l + __u) / 2;
26 __p = (void *) (((const char *) __base) +
27 (__idx * __size));
28 __comparison = (*__compar) (__key,
29 __p);
30 if (__comparison < 0)
31 __u = __idx;
32 else if (__comparison > 0)
33 __l = __idx + 1;
34 else
35 return (void *)
36 __p;
37 }
38 return ((void *)0);
39 }