From owner-freebsd-current Wed May 15 12:42: 5 2002 Delivered-To: freebsd-current@freebsd.org Received: from alpha.develop.ferrari.net (host1.ferrari-electronic.de [62.159.79.193]) by hub.freebsd.org (Postfix) with ESMTP id 253CD37B40D; Wed, 15 May 2002 12:41:56 -0700 (PDT) Received: (from robert@localhost) by alpha.develop.ferrari.net (8.11.6/8.11.6/SuSE Linux 0.5) id g4FJY6o31405; Wed, 15 May 2002 21:34:06 +0200 Date: Wed, 15 May 2002 21:34:06 +0200 From: Robert Drehmel To: Akinori MUSHA Cc: audit@FreeBSD.org, current@FreeBSD.org Subject: Re: moused(8): char signed-ness problem with gcc 3.1 Message-ID: <20020515213406.A30720@alpha.develop.ferrari.net> References: <86sn4t8fzp.wl@archon.local.idaemons.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <86sn4t8fzp.wl@archon.local.idaemons.org> User-Agent: Mutt/1.3.22.1i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, May 16, 2002 at 02:42:34AM +0900, Akinori MUSHA wrote: > I observed gcc 2.95.4 and gcc 3.1 interpret (or maybe optimize) the > following code differently (CFLAGS=-O): > > int main(void) > { > unsigned char i = 127; > printf("%d\n", ((char)(i << 1)) / 2); > return 0; > } I think GCC 3.1 does a logical right shift by one to optimize the division by two instead of an arithmetic right shift. ciao, -robert To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message