From owner-freebsd-chat@FreeBSD.ORG Wed Feb 13 10:39:45 2008 Return-Path: Delivered-To: freebsd-chat@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9E1ED16A421 for ; Wed, 13 Feb 2008 10:39:45 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (unknown [IPv6:2a01:170:102f::2]) by mx1.freebsd.org (Postfix) with ESMTP id 1D91313C4D5 for ; Wed, 13 Feb 2008 10:39:44 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.1/8.14.1) with ESMTP id m1DAdcxv093070; Wed, 13 Feb 2008 11:39:43 +0100 (CET) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.1/8.14.1/Submit) id m1DAdcj0093069; Wed, 13 Feb 2008 11:39:38 +0100 (CET) (envelope-from olli) Date: Wed, 13 Feb 2008 11:39:38 +0100 (CET) Message-Id: <200802131039.m1DAdcj0093069@lurza.secnetix.de> From: Oliver Fromme To: freebsd-chat@FreeBSD.ORG, deeptech71@gmail.com In-Reply-To: <47B24480.9020001@gmail.com> X-Newsgroups: list.freebsd-chat User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/6.2-STABLE-20070808 (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Wed, 13 Feb 2008 11:39:43 +0100 (CET) Cc: Subject: Re: bits wrap when leftshifting non-constant amounts X-BeenThere: freebsd-chat@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-chat@FreeBSD.ORG, deeptech71@gmail.com List-Id: Non technical items related to the community List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Feb 2008 10:39:45 -0000 deeptech71@gmail.com wrote: > My gcc 3.4.6 behaves weirdly when left shifting, and I couldn't > find any info on this. > [...] > It seems that lsh is first moduloed with the width of int. What the hell? C99 standard, section 6.5.7 "Bitwise shift operators", page 84: "If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behaviour is undefined." Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd "C is quirky, flawed, and an enormous success." -- Dennis M. Ritchie.