Article View: gnu.g++.bug
Article #195bug in gcc2.2.2 (terminating condition in for(;;) loop)
From: Rick Kitts
Date: Wed, 29 Jul 1992 03:16
Date: Wed, 29 Jul 1992 03:16
49 lines
1826 bytes
1826 bytes
Look below for "Bad Code" (no quotes). For some reason I was forced
to add the myint assignment above it. I have commented out the offending
bit of code. The symptom is that the loop never terminates when the
expression evaluates to -1. My compiler options were:
-O -I..
This function, by the way, is from a package in alt.sources called forms,
available on wuarchive.wustl.edu. I apologize in advance for such a
vague bug report. I'm working on a rather tight deadline and haven't
the time just now to give you more information. I'll keep a record of
this and try to provide more detailslater.
FmPutFld(i, line)
int i;
char *line;
{
int x, y, oldx;
int myint;
if( i < 0 || i > lastfield ) return(E_FMBFLD);
getyx(fields[i].win, y, oldx); /* save cursor location */
wattron(fields[i].win, fields[i].attrib); /* turn on attributes */
mvwaddstr(fields[i].win, 0, 0, line); /* put line in field */
/* Blank fill rest of field */
myint = (fields[i].endx - fields[i].startx) - strlen(line);
/* HERE IT IS!!! */
/* Bad Code. Bad, bad, naughty code.
for( x = 0 ; x <= (fields[i].endx - fields[i].startx) - strlen(line); x++) */
/* And this is the good, wholesome code. */
for( x = 0 ; x <= myint; x++)
{
waddch(fields[i].win, ' ');
}
wmove(fields[i].win, 0, oldx);
wrefresh(fields[i].win);
return(OK);
}
Technical Details
Message-ID:
<y=nmkl-.rkitts@netcom.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!netcom.com!rkittsShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!netcom.com!rkitts From: rkitts@netcom.com (Rick Kitts) Subject: bug in gcc2.2.2 (terminating condition in for(;;) loop) Message-ID: <y=nmkl-.rkitts@netcom.com> Sender: gnulists@ai.mit.edu Organization: Netcom - Online Communication Services (408 241-9760 guest) Distribution: gnu Date: Wed, 29 Jul 1992 03:16:29 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 50