From owner-freebsd-current Fri Dec 13 7:10:14 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4012B37B401; Fri, 13 Dec 2002 07:10:12 -0800 (PST) Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id CD7CB43E4A; Fri, 13 Dec 2002 07:10:06 -0800 (PST) (envelope-from ru@whale.sunbay.crimea.ua) Received: from whale.sunbay.crimea.ua (ru@localhost [127.0.0.1]) by whale.sunbay.crimea.ua (8.12.6/8.12.6/Sunbay) with ESMTP id gBDF9ilx007748 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Fri, 13 Dec 2002 17:09:44 +0200 (EET) (envelope-from ru@whale.sunbay.crimea.ua) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.12.6/8.12.6/Submit) id gBDF9gKx007738; Fri, 13 Dec 2002 17:09:42 +0200 (EET) Date: Fri, 13 Dec 2002 17:09:42 +0200 From: Ruslan Ermilov To: "Andrey A. Chernov" Cc: bwk@bell-labs.com, obrien@FreeBSD.ORG, current@FreeBSD.ORG Subject: Re: New AWK bug with collating Message-ID: <20021213150942.GE86638@sunbay.com> References: <20021213122654.GA32014@nagual.pp.ru> <20021213123240.GC86638@sunbay.com> <20021213134106.GA32832@nagual.pp.ru> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="SNIs70sCzqvszXB4" Content-Disposition: inline In-Reply-To: <20021213134106.GA32832@nagual.pp.ru> User-Agent: Mutt/1.5.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 --SNIs70sCzqvszXB4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 13, 2002 at 04:41:06PM +0300, Andrey A. Chernov wrote: > On Fri, Dec 13, 2002 at 14:32:40 +0200, Ruslan Ermilov wrote: > > Pardon my ignorance here, but the following fragment > > returns -1, doesn't it? > >=20 > > #include > > void > > main(void) > > { > > int i; > >=20 > > i =3D (unsigned char)1 - (unsigned char)2; > > printf("%d\n", i); > > } >=20 > It very depends on compiler, i.e. does it implements "value preseving" or= =20 > "unsigned preserving" for 'char' type conversions. Or ANSI C vs. common C= =20 > mode. Better be safe for both. >=20 > Read 6.10.1.1 section here: > http://wwwrsphysse.anu.edu.au/doc/DUhelp/AQTLTBTE/DOCU_067.HTM >=20 This is handled by the -traditional flag of gcc(1): : `-traditional' :=20 : Attempt to support some aspects of traditional C compilers. : Specifically: :=20 [...] :=20 : * Integer types `unsigned short' and `unsigned char' promote to : `unsigned int'. With -traditional, the code I quoted still produces -1. In any case, this section doesn't apply to this case because no conversion described in section 6.10 is ever done here, since both operands are of the same type, "unsigned char". Cheers, --=20 Ruslan Ermilov Sysadmin and DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age --SNIs70sCzqvszXB4 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE9+fg1Ukv4P6juNwoRAmsAAJ9VtuCbomXUhdZYHfHLPHZUuI2jtQCeOBCG O+ccxDhwjfWmU3vzHzZjCP4= =PYhC -----END PGP SIGNATURE----- --SNIs70sCzqvszXB4-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message