From owner-svn-src-all@FreeBSD.ORG Sun Jan 25 19:16:39 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7743B10656EE; Sun, 25 Jan 2009 19:16:39 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.229]) by mx1.freebsd.org (Postfix) with ESMTP id 3E4B18FC13; Sun, 25 Jan 2009 19:16:39 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: by rv-out-0506.google.com with SMTP id b25so5664348rvf.43 for ; Sun, 25 Jan 2009 11:16:39 -0800 (PST) Received: by 10.141.106.14 with SMTP id i14mr2148331rvm.143.1232910998805; Sun, 25 Jan 2009 11:16:38 -0800 (PST) Received: from ?10.0.1.199? (udp005586uds.hawaiiantel.net [72.234.105.237]) by mx.google.com with ESMTPS id k41sm12331632rvb.3.2009.01.25.11.16.36 (version=SSLv3 cipher=RC4-MD5); Sun, 25 Jan 2009 11:16:37 -0800 (PST) Date: Sun, 25 Jan 2009 09:14:03 -1000 (HST) From: Jeff Roberson X-X-Sender: jroberson@desktop To: Christoph Mallon In-Reply-To: <497CB95A.109@gmx.de> Message-ID: <20090125091247.Y983@desktop> References: <200901251838.n0PIcgXk024858@svn.freebsd.org> <20090125085419.O983@desktop> <497CB95A.109@gmx.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, Jeff Roberson , src-committers@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r187693 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jan 2009 19:16:40 -0000 On Sun, 25 Jan 2009, Christoph Mallon wrote: > Jeff Roberson schrieb: >> On Sun, 25 Jan 2009, Jeff Roberson wrote: >> >>> Author: jeff >>> Date: Sun Jan 25 18:38:42 2009 >>> New Revision: 187693 >>> URL: http://svn.freebsd.org/changeset/base/187693 >>> >>> Log: >>> - bit has to be fd_mask to work properly on 64bit platforms. Constants >>> must also be cast even though the result ultimately is promoted >>> to 64bit. >>> - Correct a loop index upper bound in selscan(). >> >> Sorry about that, should've tested my earlier patch for more than a couple >> of days. I seldom remember c's integer promotion rules as they relate to >> constants. You'd think they'd make it easy on us and just promote it to >> the largest type in the expression/lvalue. I'm not sure why they don't. >> Perhaps the more careful among you knows the answer. > > The rule for operations is quite simple: An operation never cares for the > type of its user. It only uses the type of the operand(s) to determine its > result type. So for a = b + c the type of the result of + only depends on the > types of b and c, but never on a. > Integer literals have a bit ugly rules what type they are: It depends on the > base (!) and on the magnitude of the literal. > If in doubt and you need a specific type (and maybe making it more clear for > a reader) then cast. > I'm familiar with the rule, what I don't know is the rationale. It would've been much more convenient if they did care for the user. In what case does the base matter? If you use a literal large enough the compiler conveniently complains. However, in this case the shift value was computed and applied to 1 which overflowed before being assigned to a 64bit value. Thanks, Jeff