From owner-freebsd-stable@FreeBSD.ORG Wed Dec 22 14:14:52 2004 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E0E3616A4CE for ; Wed, 22 Dec 2004 14:14:52 +0000 (GMT) Received: from av3-2-sn4.m-sp.skanova.net (av3-2-sn4.m-sp.skanova.net [81.228.10.113]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0EB4F43D1D for ; Wed, 22 Dec 2004 14:14:52 +0000 (GMT) (envelope-from ertr1013@student.uu.se) Received: by av3-2-sn4.m-sp.skanova.net (Postfix, from userid 502) id 45FBE37E83; Wed, 22 Dec 2004 15:14:51 +0100 (CET) Received: from smtp4-2-sn4.m-sp.skanova.net (smtp4-2-sn4.m-sp.skanova.net [81.228.10.180]) by av3-2-sn4.m-sp.skanova.net (Postfix) with ESMTP id 377FB37E78 for ; Wed, 22 Dec 2004 15:14:51 +0100 (CET) Received: from falcon.midgard.homeip.net (h201n1fls24o1048.bredband.comhem.se [212.181.162.201]) by smtp4-2-sn4.m-sp.skanova.net (Postfix) with SMTP id 05B1837E42 for ; Wed, 22 Dec 2004 15:14:50 +0100 (CET) Received: (qmail 52043 invoked by uid 1001); 22 Dec 2004 14:14:50 -0000 Date: Wed, 22 Dec 2004 15:14:50 +0100 From: Erik Trulsson To: Pete French Message-ID: <20041222141450.GA51987@falcon.midgard.homeip.net> Mail-Followup-To: Pete French , brett@lariat.org, colin.percival@wadham.ox.ac.uk, stable@freebsd.org References: <20041221192924.GA27658@falcon.midgard.homeip.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6i cc: brett@lariat.org cc: stable@freebsd.org cc: colin.percival@wadham.ox.ac.uk Subject: Re: Will there be a 5.3.1? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Dec 2004 14:14:53 -0000 On Wed, Dec 22, 2004 at 12:26:03PM +0000, Pete French wrote: > > Buggy compilers are indefensible, yes, but why try to apologise for it? > > I dont see it as a bug. Without an 'L' the right hand side of that > expression is a 16 bit int. For which 65536 is out of range. If I > wrote 'int y = 65535; long x = y;' then I would get the same result for > the same reason. Wrong. With 16-bit int the constant 65536 has type long. The type of a decimal integer constant without any suffix is the first of 'int', 'long', 'long long' in which the constant can be represented. (For C89 it was the first of 'int', 'long', 'unsigned long') (See 6.4.4.1 in the C99 standard.) Your example of 'int y = 65535; long x = y;' on the other hand causes implementation-defined behaviour for 16-bit ints. (As do all other instances of overflow for signed integer types.) > > The correct line is 'long x = 65535L;' which specifies that the constant > is a long. In fact aren't situations like this the precise reason for > having the 'L' as part of the language ? > > > 'long x = 65535;' will not set x to -1, even with 16-bit ints. > > It will and does on certain compilers unfortunately. No doubt, but if it does the compilers are buggy. -- Erik Trulsson ertr1013@student.uu.se