This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: A possible gcc bug?
- From: Jakub Jelinek <jakub at redhat dot com>
- To: David Brown <david at westcontrol dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Fri, 7 Sep 2018 09:47:27 +0200
- Subject: Re: A possible gcc bug?
- References: <72e169ab-5f87-3a14-d099-c30301dc68bc@westcontrol.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Sep 07, 2018 at 08:57:25AM +0200, David Brown wrote:
> I am always wary of saying there might be a compiler bug - usually it is a
> bug in the user code. But this time I am very suspicious. The example here
> comes from a discussion in the comp.lang.c Usenet group.
>
> Here is the code I have been testing:
>
>
> unsigned char foo_u(unsigned int v) {
> return (v & 0x7f) | (v & ~0x7f ? 0x80 : 0);
> }
>
> unsigned char foo_s(int v) {
> return (v & 0x7f) | (v & ~0x7f ? 0x80 : 0);
> }
Seems to have started with http://gcc.gnu.org/r134376, I'll have a look.
That said, can you file a bug in http://gcc.gnu.org/bugzilla/ for this, that
is where it should be tracked.
>
> unsigned char bar_s(int v) {
> int x = v & 0x7f;
> return (v & 0x7f) | (x ? 0x80 : 0);
> }
This does something different (did you mean int x = v & ~0x7f; ?).
Jakub