Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Dec 2002 17:09:42 +0200
From:      Ruslan Ermilov <ru@FreeBSD.ORG>
To:        "Andrey A. Chernov" <ache@nagual.pp.ru>
Cc:        bwk@bell-labs.com, obrien@FreeBSD.ORG, current@FreeBSD.ORG
Subject:   Re: New AWK bug with collating
Message-ID:  <20021213150942.GE86638@sunbay.com>
In-Reply-To: <20021213134106.GA32832@nagual.pp.ru>
References:  <20021213122654.GA32014@nagual.pp.ru> <20021213123240.GC86638@sunbay.com> <20021213134106.GA32832@nagual.pp.ru>

next in thread | previous in thread | raw e-mail | index | archive | help

--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 <stdio.h>
> > 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021213150942.GE86638>