From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32711 invoked by alias); 15 Mar 2004 22:02:33 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 32704 invoked from network); 15 Mar 2004 22:02:32 -0000 Received: from unknown (HELO punt.aladdin.de) (195.124.73.2) by sources.redhat.com with SMTP; 15 Mar 2004 22:02:32 -0000 Received: by punt.aladdin.de; id XAA09642; Mon, 15 Mar 2004 23:05:04 +0100 Received: from caligula.groessler.org(10.23.1.2) by punt.aladdin.de via smap (3.2) id xma009640; Mon, 15 Mar 04 23:04:34 +0100 Received: from langhals (langhals.groessler.org [10.23.1.27]) by Caligula.groessler.org (8.12.10/8.12.9) with ESMTP id i2FM1ck1000831; Mon, 15 Mar 2004 23:01:38 +0100 (CET) (envelope-from cpg@aladdin.de) Received: from langhals ([127.0.0.1] helo=langhals.aladdin.de) by langhals with esmtp (Exim 3.36 #1 (Debian)) id 1B309z-00015o-00; Mon, 15 Mar 2004 23:02:11 +0100 To: Ian Lance Taylor Cc: GCC List Subject: Re: signed/unsigned right shift From: Christian Groessler Date: Mon, 15 Mar 2004 22:02:00 -0000 Message-ID: <87ish53h24.fsf@aladdin.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-03/txt/msg00744.txt.bz2 On 03/14/2004 01:23:18 PM EST Ian Lance Taylor wrote: > >Christian Groessler writes: > >> >Correct, the multiplication is done as signed int. And it is >> >implementation >> >defined whether right shift of a negative signed int does sign fill or >> >not. >> >So both compilers are right; it is only your code that's wrong. >> > >> >C89 references: 3.3.7, 3.2.1.5, 3.2.1.1. >> >> Hmm, unfortunately I don't have the c89 standard document. Can >> somebody point me to the equvalent sections in c99? > >Integer promotions: 6.3.1.1. Sentence 2 says "If an int can represent all values of the original type, the value is converted to an int; otherwise, it is converted to an unsigned int." Seems to suggest that the conversion "unsigned short" to "signed int" is ok. But sentence 3 says "The integer promotions preserve value including sign." So shouldn't the conversion be "unsigned short" to "unsigned int"? regards, chris