Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-16 Thread Thomas David Rivers
Terry Lambert [EMAIL PROTECTED] wrote: Thomas David Rivers wrote: Well - it's not counter-intuitive on many machines... For example, on the IBM mainframe - there is an instruction to load a character into a register - but not one that loads *and* sign-extends. So, you can get much

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-16 Thread Akinori MUSHA
[CC: obrien, who has been working on bringing in gcc 3.1] At Wed, 15 May 2002 20:46:06 -0700, Bill Fenner wrote: So - yes - it seems gcc 3.1 does have a problem... Indeed - easily determined by breaking down the expression. So, who's gonna report it to gcc-bugs? knu?... int main()

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-16 Thread Bruce Evans
On Thu, 16 May 2002, Akinori MUSHA wrote: [CC: obrien, who has been working on bringing in gcc 3.1] At Wed, 15 May 2002 20:46:06 -0700, Bill Fenner wrote: So, who's gonna report it to gcc-bugs? knu?... int main() { unsigned char i = 127; char j; printf(%d\n,

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-16 Thread Akinori MUSHA
I've submitted a bug report to GCC GNATS: http://gcc.gnu.org/cgi-bin/gnatsweb.pl?database=gccpr=6677cmd=view+audit-trail Let's see how they handle this. -- / /__ __Akinori.org / MUSHA.org / ) ) ) ) / FreeBSD.org /

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-16 Thread David O'Brien
On Thu, May 16, 2002 at 08:31:19PM +0900, Akinori MUSHA wrote: So - yes - it seems gcc 3.1 does have a problem... Indeed - easily determined by breaking down the expression. So, who's gonna report it to gcc-bugs? knu?... Specifically what is the problem? Given the program below, take

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-16 Thread Bill Fenner
Specifically what is the problem? Given the program below, take the ISO-C spec and explain the problem. Or even w/o the spec -- I haven't been reading this thread. int main() { unsigned char i = 127; char j; printf(%d\n, ((char)(i 1))); This prints -2, which is

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-16 Thread David O'Brien
On Thu, May 16, 2002 at 12:06:49PM -0700, Bill Fenner wrote: Specifically what is the problem? Given the program below, take the ISO-C spec and explain the problem. Or even w/o the spec -- I haven't been reading this thread. int main() { unsigned char i = 127; char j;

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-16 Thread Christopher Weimann
On Thu, May 16, 2002 at 06:47:39AM -0400, Thomas David Rivers wrote: Terry Lambert [EMAIL PROTECTED] wrote: RS/6000's didn't used to use PPC processors at all; so it's probably intentional software compatability. I'm confused then - the one we have here seems to. There was a version

moused(8): char signed-ness problem with gcc 3.1

2002-05-15 Thread Akinori MUSHA
I observed gcc 2.95.4 and gcc 3.1 interpret (or maybe optimize) the following code differently (CFLAGS=-O): int main(void) { unsigned char i = 127; printf(%d\n, ((char)(i 1)) / 2); return 0; } gcc 2.95.4 says it's -1, whereas gcc 3.1 says it's 127. On FreeBSD char should be signed, so I

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-15 Thread Terry Lambert
Akinori MUSHA wrote: I observed gcc 2.95.4 and gcc 3.1 interpret (or maybe optimize) the following code differently (CFLAGS=-O): int main(void) { unsigned char i = 127; printf(%d\n, ((char)(i 1)) / 2); return 0; } Cool... gcc 2.95.4 says it's -1, Promotion of operand to

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-15 Thread Bill Fenner
gcc 3.1 simply defaults to unsigned chars. 127 1 = 254; 254 / 2 = 127. My machine is too slow to test this expeditiously, but I'm trying adding #define DEFAULT_SIGNED_CHAR 1 into freebsd-native.h . Bill To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-15 Thread Robert Drehmel
On Thu, May 16, 2002 at 02:42:34AM +0900, Akinori MUSHA wrote: I observed gcc 2.95.4 and gcc 3.1 interpret (or maybe optimize) the following code differently (CFLAGS=-O): int main(void) { unsigned char i = 127; printf(%d\n, ((char)(i 1)) / 2); return 0; } I think GCC 3.1 does a

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-15 Thread Terry Lambert
Bill Fenner wrote: gcc 3.1 simply defaults to unsigned chars. 127 1 = 254; 254 / 2 = 127. My machine is too slow to test this expeditiously, but I'm trying adding #define DEFAULT_SIGNED_CHAR 1 into freebsd-native.h . I will bet today's lunch money that you have found it for sure. I guess

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-15 Thread Bill Fenner
Duh. Sometimes I wish I had the patience to wait for my tests to complete before sharing my guesses. I jumped to a wildly incorrect conclusion; gcc 3.1 still defaults to signed chars. Sorry for the bizarre misdirection. Bill To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-15 Thread Terry Lambert
Bill Fenner wrote: Duh. Sometimes I wish I had the patience to wait for my tests to complete before sharing my guesses. I jumped to a wildly incorrect conclusion; gcc 3.1 still defaults to signed chars. Sorry for the bizarre misdirection. There goes my lunch money. 8-(. Man, your

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-15 Thread Thomas David Rivers
I observed gcc 2.95.4 and gcc 3.1 interpret (or maybe optimize) the following code differently (CFLAGS=-O): int main(void) { unsigned char i = 127; printf(%d\n, ((char)(i 1)) / 2); return 0; } gcc 2.95.4 says it's -1, whereas gcc 3.1 says it's 127. On FreeBSD char should

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-15 Thread Thomas David Rivers
Terry Lambert [EMAIL PROTECTED] wrote: Bill Fenner wrote: gcc 3.1 simply defaults to unsigned chars. 127 1 = 254; 254 / 2 = 127. My machine is too slow to test this expeditiously, but I'm trying adding #define DEFAULT_SIGNED_CHAR 1 into freebsd-native.h . I will bet today's lunch

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-15 Thread Bill Fenner
So - yes - it seems gcc 3.1 does have a problem... Indeed - easily determined by breaking down the expression. So, who's gonna report it to gcc-bugs? knu?... int main() { unsigned char i = 127; char j; printf(%d\n, ((char)(i 1))); j = ((char)(i 1)) / 2; printf(%d\n, j);

Re: moused(8): char signed-ness problem with gcc 3.1

2002-05-15 Thread Terry Lambert
Thomas David Rivers wrote: Well - it's not counter-intuitive on many machines... For example, on the IBM mainframe - there is an instruction to load a character into a register - but not one that loads *and* sign-extends. So, you can get much better code if characters are unsigned by