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

Reply via email to