From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21569 invoked by alias); 26 Mar 2003 18:26: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 21547 invoked by uid 71); 26 Mar 2003 18:26:01 -0000 Date: Wed, 26 Mar 2003 18:26:00 -0000 Message-ID: <20030326182601.21546.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Falk Hueffner Subject: Re: c/10226: unsigned short promotion with bitwise inversion Reply-To: Falk Hueffner X-SW-Source: 2003-03/txt/msg01821.txt.bz2 List-Id: The following reply was made to PR c/10226; it has been noted by GNATS. From: Falk Hueffner To: mmarks@internetmachines.com Cc: gcc-gnats@gcc.gnu.org Subject: Re: c/10226: unsigned short promotion with bitwise inversion Date: 26 Mar 2003 19:23:10 +0100 mmarks@internetmachines.com writes: > When two unsigned shorts (16 bit) variables are compared with one being inverted the comparison will fail. > The following code should pass, while it does generate a warning it > should instead just work. > > unsigned short A = 0xDEAD; > unsigned short B; > B = ~A; > if ( B == ~A) { > printf("Pass\n"); > } > else { > printf("Fail\n"); > } Apparently, you didn't understand the warning. The C standard mandates that "~A" will promote A to int first. So gcc is behaving correctly here. Any suggestions on how the wording of the message could be improved to be clearer? -- Falk