#234 DO loop not executing...

v3.1
closed
nobody
5
2012-08-14
2007-01-29
Leland Lucius
No

Not sure if this is a limitation of ooRexx or not, but this bit of code should produce 255 lines of output and it doesn't on Linux or OSX:

/ rexx /
NUMERIC DIGITS 40

h = 3232241151
l = 3232240896

DO ndx = l TO h
SAY ndx
END
EXIT

Leland

Discussion

  • Leland Lucius
    Leland Lucius
    2007-01-29

    Logged In: YES
    user_id=1024716
    Originator: YES

    Oops, this is under 3.1.1.

     
  • Rick McGuire
    Rick McGuire
    2007-01-29

    Logged In: YES
    user_id=1125291
    Originator: NO

    One of the loop optimizations which attempted to detect if the loop iterators were integer values was failing when the values were between 231 and 232-1.

     
  • Leland Lucius
    Leland Lucius
    2007-02-01

    Logged In: YES
    user_id=1024716
    Originator: YES

    Was this the bit?

        RexxObject *temp = result->integerValue(number_digits());                                                                   
        if (temp != TheNilObject) {                                                                                                 
            result = temp;                                                                                                          
        }
    

    If so, what would be the correction? (Other than just commenting it.)

     
  • Logged In: YES
    user_id=662126
    Originator: NO

    AFAICT the fix is in the latest CVS (although the Status was not changed to "Pending" yet). Running "cvs diff -D 2007-01-28" yields:

    ---------------------- cut here ------------------------
    Index: kernel/classes/NumberStringClass.cpp
    ===================================================================
    RCS file: /cvsroot/oorexx/oorexx/kernel/classes/NumberStringClass.cpp,v
    retrieving revision 1.3
    retrieving revision 1.4
    diff -r1.3 -r1.4
    82,85d81
    < / is number about to overflow /
    < if (intnum > MAXPOSBASE || ((intnum == MAXPOSBASE) && (thisnum > 5))) {
    < return NO_LONG; /
    YES, return unconvertable */
    < }
    87a84,88

     // on an overflow, this will wrap to a negative number.
     if (intnum < 0)
     {
         return NO_LONG;
     }
    

    93c94
    < if ((sign == 1 && intnum > MAXPOSNUM) || (sign == -1 && intnum > MAXNEGNUM)) {


    if (intnum < 0 || sign == -1 && intnum > MAXNEGNUM) {
    Index: platform/windows/buildorx.bat
    ===================================================================
    ---------------------- cut here ------------------------

     
  • Rick McGuire
    Rick McGuire
    2007-02-01

    Logged In: YES
    user_id=1125291
    Originator: NO

    Oops, forgot to change the status. The lines you highlighted was the point where the DO was failing, but the bug itself was in the integerValue() method. Under higher digits settings, it was not correctly detecting that the value could not fit within a signed 32-bit integer value. The converted value wrapped, resulting in a negative value for the loop target. Since the new target was less than the starting value, the loop incorrectly terminated immediately.

     


Anonymous


Cancel   Add attachments