[PATCH v2] Suppress -Wcast-qual warnings in bsearch
Adhemerval Zanella
adhemerval.zanella@linaro.org
Thu Sep 30 14:49:32 GMT 2021
On 30/09/2021 07:43, Florian Weimer via Libc-alpha wrote:
> * Jonathan Wakely via Libc-alpha:
>
>> diff --git a/bits/stdlib-bsearch.h b/bits/stdlib-bsearch.h
>> index 4132dc6af0..d688ed2e15 100644
>> --- a/bits/stdlib-bsearch.h
>> +++ b/bits/stdlib-bsearch.h
>> @@ -29,14 +29,21 @@ bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size,
>> while (__l < __u)
>> {
>> __idx = (__l + __u) / 2;
>> - __p = (void *) (((const char *) __base) + (__idx * __size));
>> + __p = (const void *) (((const char *) __base) + (__idx * __size));
>> __comparison = (*__compar) (__key, __p);
>> if (__comparison < 0)
>> __u = __idx;
>> else if (__comparison > 0)
>> __l = __idx + 1;
>> else
>> +#if __GNUC_PREREQ(4, 6)
>> +# pragma GCC diagnostic push
>> +# pragma GCC diagnostic ignored "-Wcast-qual"
>> +#endif
>> return (void *) __p;
>> +#if __GNUC_PREREQ(4, 6)
>> +# pragma GCC diagnostic pop
>> +#endif
>> }
>>
>> return NULL;
>
> Patch looks okay, thanks.
>
> Reviewed-by: Florian Weimer <fweimer@redhat.com>
>
> Florian
>
I am seeing a lot of failure on x86_64 with gcc 11.1 after this
patch landed:
x86_64-linux-gnu$ grep ^FAIL tests.sum
FAIL: catgets/de/libc.cat
FAIL: catgets/test-gencat
FAIL: catgets/test1.cat
FAIL: catgets/tst-catgets
FAIL: debug/tst-chk1
FAIL: debug/tst-chk2
FAIL: debug/tst-chk3
FAIL: debug/tst-chk4
FAIL: debug/tst-chk5
FAIL: debug/tst-chk6
FAIL: debug/tst-lfschk1
FAIL: debug/tst-lfschk2
FAIL: debug/tst-lfschk3
FAIL: debug/tst-lfschk4
FAIL: debug/tst-lfschk5
FAIL: debug/tst-lfschk6
[...]
For instance some math tests shows ulps failures that does not
make much sense:
$ ./testrun.sh math/test-double-cacos
testing double (without inline functions)
Failure: Test: Imaginary part of: cacos_downward (-0x1p-52 - 0x1.0000000000001p+0 i)
Result:
is: 8.8137358701954271e-01 0x1.c34366179d424p-1
should be: 8.8137358701954315e-01 0x1.c34366179d428p-1
difference: 4.4408920985006261e-16 0x1.0000000000000p-51
ulp : 4.0000
max.ulp : 3.0000
Failure: Test: Imaginary part of: cacos_downward (-0x1p-52 - 0x1.000002p+0 i)
Result:
is: 8.8137367131323707e-01 0x1.c34368ebb10d9p-1
should be: 8.8137367131323751e-01 0x1.c34368ebb10ddp-1
difference: 4.4408920985006261e-16 0x1.0000000000000p-51
ulp : 4.0000
max.ulp : 3.0000
[...]
Reverting fixes it.
More information about the Libc-alpha
mailing list