From owner-svn-src-all@FreeBSD.ORG Mon Jun 21 18:19:11 2010 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 DB4D9106566C; Mon, 21 Jun 2010 18:19:11 +0000 (UTC) (envelope-from xcllnt@mac.com) Received: from asmtpout024.mac.com (asmtpout024.mac.com [17.148.16.99]) by mx1.freebsd.org (Postfix) with ESMTP id B99768FC08; Mon, 21 Jun 2010 18:19:11 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=us-ascii Received: from [172.24.241.142] (natint3.juniper.net [66.129.224.36]) by asmtp024.mac.com (Sun Java(tm) System Messaging Server 6.3-8.01 (built Dec 16 2008; 32bit)) with ESMTPSA id <0L4D004G7MVY7N40@asmtp024.mac.com>; Mon, 21 Jun 2010 11:19:11 -0700 (PDT) X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx engine=6.0.2-1004200000 definitions=main-1006210102 X-Proofpoint-Virus-Version: vendor=fsecure engine=1.12.8161:2.4.5,1.2.40,4.0.166 definitions=2010-06-21_01:2010-02-06, 2010-06-21, 2010-06-20 signatures=0 From: Marcel Moolenaar In-reply-to: <20100622024652.C43995@delplex.bde.org> Date: Mon, 21 Jun 2010 11:19:10 -0700 Message-id: References: <201006200034.o5K0Y6xl041024@svn.freebsd.org> <20100622024652.C43995@delplex.bde.org> To: Bruce Evans X-Mailer: Apple Mail (2.1081) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, Marcel Moolenaar , src-committers@freebsd.org Subject: Re: svn commit: r209358 - head/cddl/contrib/opensolaris/lib/libdtrace/common 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: Mon, 21 Jun 2010 18:19:12 -0000 On Jun 21, 2010, at 10:22 AM, Bruce Evans wrote: > On Sun, 20 Jun 2010, Marcel Moolenaar wrote: > >> Log: >> Unbreak platforms with char unsigned by default. Oddly enough, GCC isn't >> satisfied with a simple cast to int in the check against EOF, so the fix >> is a bit involved by actually having to go through a temporary variable. > > Perhaps that is because gcc can see that the cast has no effect, so the > comparison can never be true if `c' is an unsigned char (unless unsigned > char has the same number of bits as signed int), but it cannot see that > the conversion to the temporary variable has the same null effect. Very likely. However, by casting from char to int we do tell the compiler that this not grounds for a warning and as such we expect the compiler to treat this as any other scenario in which the compiler can infer that a condition is always true or false and as such optimize correctly. In other words: the compiler is correct in warning that (u_char != -1) is possibly not what the programmer wants, but I do expect that if we change the condition to (int != -1) by using a cast that the compiler will simply shut up and eliminate the if statement if it knows that the int will never be -1. > This remains broken, especially on platforms with chars unsigned. I can't make that claim. The expansion of the macro in the failing case may actually not have a problem by virtue of it working on an array of unsigned char. For all I know, EOF is never encountered and the check is simply not applicable. FYI, -- Marcel Moolenaar xcllnt@mac.com