From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30178 invoked by alias); 14 Mar 2004 18:23:28 -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 30083 invoked from network); 14 Mar 2004 18:23:27 -0000 Received: from unknown (HELO yosemite.airs.com) (209.128.65.135) by sources.redhat.com with SMTP; 14 Mar 2004 18:23:27 -0000 Received: (qmail 14958 invoked by uid 10); 14 Mar 2004 18:23:27 -0000 Received: (qmail 6969 invoked by uid 500); 14 Mar 2004 18:23:19 -0000 From: Ian Lance Taylor To: Christian Groessler Cc: GCC List Subject: Re: signed/unsigned right shift References: <87vfl7s3lf.fsf@aladdin.de> Date: Sun, 14 Mar 2004 18:23:00 -0000 In-Reply-To: <87vfl7s3lf.fsf@aladdin.de> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-03/txt/msg00629.txt.bz2 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? Usual arithmetic conversions performed on operands of multiplication: 6.5.5. Usual arithmetic conversions: 6.3.1.8. Note in particular "the integer promotions are performed on both operands." Integer promotions: 6.3.1.1. Right shift of signed negative value implementation defined: 6.5.7. Ian