From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1342 invoked by alias); 26 Mar 2003 23:16:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 1328 invoked by uid 71); 26 Mar 2003 23:16:01 -0000 Date: Thu, 27 Mar 2003 00:16:00 -0000 Message-ID: <20030326231601.1327.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Michael Marks Subject: RE: c/10226: unsigned short promotion with bitwise inversion Reply-To: Michael Marks X-SW-Source: 2003-03/txt/msg01857.txt.bz2 List-Id: The following reply was made to PR c/10226; it has been noted by GNATS. From: Michael Marks To: 'Falk Hueffner' , Glen Nakamura Cc: gcc-gnats@gcc.gnu.org Subject: RE: c/10226: unsigned short promotion with bitwise inversion Date: Wed, 26 Mar 2003 15:10:54 -0800 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C2F3EC.F3696FC0 Content-Type: text/plain; charset="iso-8859-1" Guys, How about... warning: comparison will will promote to ~(unsigned) which will zero extend before ~ operation -----Original Message----- From: Falk Hueffner [mailto:falk.hueffner@student.uni-tuebingen.de] Sent: Wednesday, March 26, 2003 2:54 PM To: Glen Nakamura Cc: Michael Marks; gcc-gnats@gcc.gnu.org Subject: Re: c/10226: unsigned short promotion with bitwise inversion Glen Nakamura writes: > On Wed, Mar 26, 2003 at 11:19:58PM +0100, Falk Hueffner wrote: > > Glen Nakamura writes: > > > How about one of these: > > > warning: comparison of promoted ~unsigned with unsigned is always false > > > warning: comparison of ~(promoted unsigned) with unsigned is always false > > > > Yes, that makes it even clearer. I'd prefer the second variant. (BTW, > > funny, the optimizer doesn't seem to realize it's always false...) > > It does on my system (GCC 3.3): Well, yeah, it's simply constant folding there. What I meant is that gcc doesn't optimize int f(unsigned short a, unsigned short b) { return b == ~a; } to int f(unsigned short a, unsigned short b) { return 0; } -- Falk ------_=_NextPart_001_01C2F3EC.F3696FC0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: c/10226: unsigned short promotion with bitwise = inversion

Guys,
How about...
warning: comparison will will promote to ~(unsigned) = which will zero extend before ~ operation

-----Original Message-----
From: Falk Hueffner [mailto:falk.hueff= ner@student.uni-tuebingen.de]
Sent: Wednesday, March 26, 2003 2:54 PM
To: Glen Nakamura
Cc: Michael Marks; gcc-gnats@gcc.gnu.org
Subject: Re: c/10226: unsigned short promotion with = bitwise inversion


Glen Nakamura <glen@imodulo.com> writes:

> On Wed, Mar 26, 2003 at 11:19:58PM +0100, Falk = Hueffner wrote:
> > Glen Nakamura <glen@imodulo.com> = writes:
> > > How about one of these:
> > > warning: comparison of promoted = ~unsigned with unsigned is always false
> > > warning: comparison of ~(promoted = unsigned) with unsigned is always false
> >
> > Yes, that makes it even clearer. I'd = prefer the second variant.  (BTW,
> > funny, the optimizer doesn't seem to = realize it's always false...)
>
> It does on my system (GCC 3.3):

Well, yeah, it's simply constant folding there. What = I meant is that
gcc doesn't optimize

int f(unsigned short a, unsigned short b) { return b = =3D=3D ~a; }

to

int f(unsigned short a, unsigned short b) { return 0; = }

--
        Falk

------_=_NextPart_001_01C2F3EC.F3696FC0--