From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8581 invoked by alias); 26 Mar 2003 22:36: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 8563 invoked by uid 71); 26 Mar 2003 22:36:00 -0000 Date: Wed, 26 Mar 2003 22:36:00 -0000 Message-ID: <20030326223600.8561.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Glen Nakamura Subject: Re: c/10226: unsigned short promotion with bitwise inversion Reply-To: Glen Nakamura X-SW-Source: 2003-03/txt/msg01853.txt.bz2 List-Id: The following reply was made to PR c/10226; it has been noted by GNATS. From: Glen Nakamura To: Falk Hueffner Cc: Michael Marks , gcc-gnats@gcc.gnu.org Subject: Re: c/10226: unsigned short promotion with bitwise inversion Date: Wed, 26 Mar 2003 12:30:54 -1000 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...) > > -- > Falk It does on my system (GCC 3.3): .LC1: .string "Fail" .text .p2align 4,,15 .globl main .type main, @function main: pushl %ebp movl %esp, %ebp subl $8, %esp andl $-16, %esp movl $.LC1, (%esp) call puts movl %ebp, %esp xorl %eax, %eax popl %ebp ret But, as I mentioned before my suggestion won't work for other comparisons... the warning probably needs to be generic enough for all of the following cases: unsigned (char|short) (==|!=|<|<=|>|>=) ~unsigned (char|short) which is *not* always false but could have unexpected results. - glen