TIP: Click on subject to list as thread! ANSI
echo: cis.os9.68000.osk
to: all
from: Bob van der Poel 76510,2203
date: 1993-07-26 19:09:16
subject: #gnu c bug

#: 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.

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.