bugGNU Octave - Bugs: bug #59229, Regression in handling inf as...


bug #59229: Regression in handling inf as for-loop limits

Submitted by:  None
Submitted on:  Tue 06 Oct 2020 01:33:19 PM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  dev
Operating System:  GNU/Linux

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Sun 07 Feb 2021 11:24:11 PM UTC, comment #4: 

Verified it passes the test in tst_inf_loop.m.  Marking as Fixed and closing report.

Rik <rik5>
Project Administrator
Sat 06 Feb 2021 03:50:46 PM UTC, comment #3: 

I pushed the following changeset:


Marking as ready for test.

John W. Eaton <jwe>
Project Administrator
Thu 08 Oct 2020 05:44:06 PM UTC, comment #2: 

Yes, colon expressions that use Inf but have 0 elements should produce an empty matrix.  I'll look at fixing that.

John W. Eaton <jwe>
Project Administrator
Wed 07 Oct 2020 08:26:11 PM UTC, comment #1: 


I'm attaching an m-file (tst_inf_loop.m) which can be run to show the error.

This is related so I note it here

octave:1> x = Inf:0
error: out of memory or dimension too large for Octave's index type

In Octave 6.1 this just creates an empty matrix.

(file #49933)

Rik <rik5>
Project Administrator
Tue 06 Oct 2020 01:33:19 PM UTC, original submission:  

This code used to work in Octave 5.2 but now causes an out of memory error in Octave 7.0.0 (dev):

lo = +inf;
hi = -inf;
# lo and hi are refined here as required by the problem instance
# If the instance is empty, then lo and hi are unchanged.
for i = lo:hi
  # do something
# The idea is that for empty problem instances,
# the for-loop would become empty as well and trivially backtrack.

This used to work as intended but now results in this error in Octave 7.0.0:

error: out of memory or dimension too large for Octave's index type

The problem is specific to the use of inf or -inf in for-loop limits, because the following loop does not cause an error:

lo = +1e30; # some value much bigger than memory would allow
hi = -1e30;
for i = lo:hi
  # do something
# Empty loop trivially exits.

The problem has been temporarily worked around by using a very large finite value instead of inf.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #49933:  tst_inf_loop.m added by rik5 (68B - text/x-matlab)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Updated the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-02-07 rik5 StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
    2021-02-06 jwe StatusConfirmed => Ready For Test
    2020-10-07 rik5 StatusNone => Confirmed
    2020-10-07 rik5 Attached File- => Added tst_inf_loop.m, #49933

    Back to the top

    Powered by Savane 3.6