Post Reply 
Bug implementing infinite Recursion?
01-04-2018, 04:40 PM (This post was last modified: 01-04-2018 04:45 PM by StephenG1CMZ.)
Post: #1
Bug implementing infinite Recursion?
I unintentionally implemented an infinite recursion of a function taking a list which should return a real integer (the number of items counter in the list).

The infinite recursion behaved unexpectedly.
The Prime only limits recursion depth in the CAS.

But instead of crashing, the code that should never return an integer, instead returns tthe input list and continues to execute (after several seconds).


  //Also, useful temporary results 

 //Caution ऊਉऊ be much slower but may be faster
 //INT LST 8000 DUPS:0.2s

 //Count how many duplicates in a sortedlist,Return a REAL INT
 //({1,9,9}=1 dup, {1,2,2,3,3,3}=3 dup)
 //Timings consistent 0.3s
    IF SortedLST(II) ==SortedLST(II+1) THEN

 EXPORT ListExamples()
 //In real use, use XXX:=List...()
  LOCAL LL:={1,2,3,4,5,6,7,8,9};
  //RETURN 0; 

(A fragment from my List V1.2 code, before bug fix. The intended return procedurename should be ..._SORTED)

Instead of printing C and erroring, the code fragment prints
{Input list}

At the point where D is printed, the count contains a list instead of an integer, which could lead to subsequent bugs in the user code...It would be better if the recursion were trapped and subsequent code not executed.

Stephen Lewkowicz (G1CMZ)
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
Bug implementing infinite Recursion? - StephenG1CMZ - 01-04-2018 04:40 PM

User(s) browsing this thread: 1 Guest(s)