From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8831 invoked by alias); 15 Mar 2004 22:17:06 -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 8821 invoked from network); 15 Mar 2004 22:17:05 -0000 Received: from unknown (HELO yosemite.airs.com) (209.128.65.135) by sources.redhat.com with SMTP; 15 Mar 2004 22:17:05 -0000 Received: (qmail 29375 invoked by uid 10); 15 Mar 2004 22:17:05 -0000 Received: (qmail 14508 invoked by uid 500); 15 Mar 2004 22:16:55 -0000 From: Ian Lance Taylor To: Christian Groessler Cc: GCC List Subject: Re: signed/unsigned right shift References: <87ish53h24.fsf@aladdin.de> Date: Mon, 15 Mar 2004 22:17:00 -0000 In-Reply-To: <87ish53h24.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/msg00746.txt.bz2 Christian Groessler writes: > 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"? Sentence 3 means that both the value and the sign of the value (i.e., positive or negative) are preserved. Your suggestion would be expressed as "The integer promotions preserve value including signedness." K&R C was signedness preserving. ISO C is value preserving. A quick Google search turned up this page on the topic: http://ou800doc.caldera.com/SDK_cprog/_Background.html Ian