94084c
commit 80a009119ba2330768120476aaad63767b81d543
94084c
Author: Jonathan Wakely <jwakely@redhat.com>
94084c
Date:   Wed May 19 16:48:19 2021 +0100
94084c
94084c
    Suppress -Wcast-qual warnings in bsearch
94084c
    
94084c
    The first cast to (void *) is redundant but should be (const void *)
94084c
    anyway, because that's the type of the lvalue being assigned to.
94084c
    
94084c
    The second cast is necessary and intentionally not const-correct, so
94084c
    tell the compiler not to warn about it.
94084c
    
94084c
    Reviewed-by: Florian Weimer <fweimer@redhat.com>
94084c
    (cherry picked from commit a725ff1de965f4cc4f36a7e8ae795d40ca0350d7)
94084c
94084c
diff --git a/bits/stdlib-bsearch.h b/bits/stdlib-bsearch.h
94084c
index 4132dc6af0077f31..d688ed2e15678e9c 100644
94084c
--- a/bits/stdlib-bsearch.h
94084c
+++ b/bits/stdlib-bsearch.h
94084c
@@ -29,14 +29,21 @@ bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size,
94084c
   while (__l < __u)
94084c
     {
94084c
       __idx = (__l + __u) / 2;
94084c
-      __p = (void *) (((const char *) __base) + (__idx * __size));
94084c
+      __p = (const void *) (((const char *) __base) + (__idx * __size));
94084c
       __comparison = (*__compar) (__key, __p);
94084c
       if (__comparison < 0)
94084c
 	__u = __idx;
94084c
       else if (__comparison > 0)
94084c
 	__l = __idx + 1;
94084c
       else
94084c
+#if __GNUC_PREREQ(4, 6)
94084c
+# pragma GCC diagnostic push
94084c
+# pragma GCC diagnostic ignored "-Wcast-qual"
94084c
+#endif
94084c
 	return (void *) __p;
94084c
+#if __GNUC_PREREQ(4, 6)
94084c
+# pragma GCC diagnostic pop
94084c
+#endif
94084c
     }
94084c
 
94084c
   return NULL;