public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: GNU C Library <libc-alpha@sourceware.org>,
	Joseph Myers <joseph@codesourcery.com>
Subject: Re: [PATCH v2] Suppress -Wcast-qual warnings in bsearch
Date: Thu, 30 Sep 2021 17:52:42 +0100	[thread overview]
Message-ID: <CACb0b4nQGxUcm0a91rVFQXBLswmquB5DTyrX++fifb=JtS0NqQ@mail.gmail.com> (raw)
In-Reply-To: <069fcec4-d81f-3ea8-d87c-ff3b281dbe71@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 2792 bytes --]

On Thu, 30 Sept 2021 at 15:49, Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> 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.

Huh, I wonder why I didn't see these. Sorry. I'll see if Joseph's
suggestion helps (as attached) or I'll revert it.

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1049 bytes --]

commit f1763cd2d3b77582309288198e56de5d883b425a
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Sep 30 17:24:54 2021 +0100

    stdlib: Add braces around return statement in bsearch
    
    The diagnostic pragmas are apparently interpreted as the statement
    following the else, so add braces around them to create a block
    statement containing the pragmas and the return statement.
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

diff --git a/bits/stdlib-bsearch.h b/bits/stdlib-bsearch.h
index d688ed2e15..c4b485edf8 100644
--- a/bits/stdlib-bsearch.h
+++ b/bits/stdlib-bsearch.h
@@ -36,14 +36,16 @@ bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size,
       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;
+          return (void *) __p;
 #if __GNUC_PREREQ(4, 6)
 # pragma GCC diagnostic pop
 #endif
+        }
     }
 
   return NULL;

  parent reply	other threads:[~2021-09-30 16:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19 14:14 [PATCH] " Jonathan Wakely
2021-05-19 15:37 ` Joseph Myers
2021-05-19 15:50   ` Jonathan Wakely
2021-06-01 10:09     ` [PATCH v3] " Jonathan Wakely
2021-09-30  9:22     ` [PATCH v2] " Jonathan Wakely
2021-09-30 10:43       ` Florian Weimer
2021-09-30 14:49         ` Adhemerval Zanella
2021-09-30 15:07           ` Joseph Myers
2021-09-30 15:19             ` Adhemerval Zanella
2021-09-30 15:30               ` Andreas Schwab
2021-09-30 16:41               ` Florian Weimer
2021-09-30 16:42               ` Joseph Myers
2021-09-30 16:52           ` Jonathan Wakely [this message]
2021-09-30 17:54           ` H.J. Lu
2021-09-30 18:04             ` Florian Weimer
2021-09-30 18:09               ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACb0b4nQGxUcm0a91rVFQXBLswmquB5DTyrX++fifb=JtS0NqQ@mail.gmail.com' \
    --to=jwakely@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).