www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/11/10/19:03:10

Date: Thu, 10 Nov 1994 12:52:02 -0600 (CST)
From: Michael Glass <glass AT steve DOT iit DOT edu>
Subject: GCC: isdigit() bug?
To: djgpp mailing list <djgpp AT sun DOT soe DOT clarkson DOT edu>

I think I have found a bug in "isdigit" in GCC for the PC.

The code for isdigit expands in-line as follows:

     movsx    edx, ...          ; Load character in question
     mov      cl, [edx+...]     ; Index into translation table
     and      cl, 4h            ; Check bit 2 is on or off...
     ...                        ;    (takes several instructions)

The movsx should be movzx.  The text we are processing has some
characters in the x80 to xFF range, so the sign-extended move
is causing edx to index *backward* from the start of the table.

Also disturbing me is that I think I also caught Borland TC
doing the same thing.  Unfortunately I didn't look at the
generated code (the Borland debugger is deficient in this respect),
but I did observe erratic behavior.

-- Michael Glass             | Partnership for a
   glass AT steve DOT iit DOT edu       |   Bug-Free America



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019