From: Josh Huber Date: 2000-10-20T21:59:50+09:00 Subject: [ruby-talk:5709] build warning... --oTHb8nViIGeoXxdp Content-Type: multipart/mixed; boundary="QTprm0S8XgL7H0Dt" Content-Disposition: inline --QTprm0S8XgL7H0Dt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable My primary platform is powerpc, and I'm really used to seeing: 'Comparison always true/false due to limited range in data type' spit out by gcc due to the fact that on x86 (and other LE archs) char defaults to signed char, but on the ppc (and ARM, don't know about sparc) char =3D=3D unsigned char. for example: void main(void) { char t; int i =3D -1; t =3D i; printf("val: %d\n", (int)t); } prints val =3D 255 on powerpc, but val =3D -1 on intel. normally this can cause major problems, and I saw this while building ruby. the warning was actually in the parser... line 3520 of parse.y contains is_identchar(tok()[0]). tok() (tokenbuf) is a char *, and is_identchar does this: ((int)(c))!=3D-1 ... of course, this will always be true on ppc systems. now, I don't think there's really a problem, because I _think_ tokenbuf characters are never set to a negative value. (could be wrong, but I didn't see any cases). in any case, a fix is attached. this would fix future (obscure) bugs, and at least get rid of that warning. (that warning is flagged on the debian buildd for powerpc because it is usually an indication that something is broken). Thanks, --=20 Josh | huber@mclx.com | 1024D/6B21489A 61F0 6138 BE7B FEBF A223 E9D1 BFE1 2065 6B21 489A --QTprm0S8XgL7H0Dt Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=ruby-signed-char Content-Transfer-Encoding: quoted-printable --- ruby-1.6.1/build-tree/ruby-1.6.1/parse.y Fri Oct 20 08:57:16 2000 +++ parse.y Fri Oct 20 08:56:31 2000 @@ -1822,7 +1822,7 @@ =20 #define is_identchar(c) (((int)(c))!=3D-1&&(ISALNUM(c) || (c) =3D=3D '_' |= | ismbchar(c))) =20 -static char *tokenbuf =3D NULL; +static signed char *tokenbuf =3D NULL; static int tokidx, toksiz =3D 0; =20 static NODE *str_extend(); @@ -2080,7 +2080,7 @@ =20 static void tokadd(c) - char c; + signed char c; { tokenbuf[tokidx++] =3D c; if (tokidx >=3D toksiz) { --QTprm0S8XgL7H0Dt-- --oTHb8nViIGeoXxdp Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.3 (GNU/Linux) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjnwQbUACgkQv+EgZWshSJrZUwCgmwny7VUa8+c+wPiwDdii8WOZ zDsAnA5Ts3dw8GvOZAMoukk15i6D2ww/ =+iGM -----END PGP SIGNATURE----- --oTHb8nViIGeoXxdp--