#: 18452 S12/OS9/68000 (OSK)
26-Jul-93 19:09:16
Sb: #gnu c bug
Fm: Bob van der Poel 76510,2203
To: all
Just thought I'd pass along an interesting bug I found in the GCC2 package! If
you compile the following program with 'gcc2 -O2 test.c -o /dd/cmds/test' it
will not work properly. However, deleting the '-O2' from the compile line fixes
it. It appears that the optimization internal to CC2 is broken. Also, if you
change the declaraction of 'c' to 'unsigned char' it appears to work okay too.
An exlicit cast in the 't=...' line doesn't help. So, until this is fixed,
you'd best not use the -O option. Would someone familiar with the GNU project
pass this report along to someone who can fix it? BTW, the version of cc2 on my
machines is 'GNU C version 2.4.1 (68k, Motorola syntax)'.
#include
#include
main()
{
char *s="1bf";
printf("the value of '%s' is '%d'\n",s,htoi(s));
}
htoi(s)
char *s;
{
register char c;
register int t=0;
while(isxdigit((char)*s))
{
c=toupper(*(s++));
c-=(c>'9') ? 55 : 48;
t=(t*16)+c;
}
return t;
}
There is 1 Reply.
|