c/10226: unsigned short promotion with bitwise inversion

Falk Hueffner falk.hueffner@student.uni-tuebingen.de
Wed Mar 26 23:06:00 GMT 2003


The following reply was made to PR c/10226; it has been noted by GNATS.

From: Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
To: Glen Nakamura <glen@imodulo.com>
Cc: Michael Marks <Michael.Marks@internetmachines.com>, gcc-gnats@gcc.gnu.org
Subject: Re: c/10226: unsigned short promotion with bitwise inversion
Date: 26 Mar 2003 23:53:41 +0100

 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 == ~a; }
 
 to
 
 int f(unsigned short a, unsigned short b) { return 0; }
 
 -- 
 	Falk



More information about the Gcc-prs mailing list