bugGNU Octave - Bugs: bug #60850, Using (end+1) on non-existent...

 
 

bug #60850: Using (end+1) on non-existent variable assignment fails in Octave 6.2.0

Submitter:  None
Submitted:  Tue 29 Jun 2021 01:09:32 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Wont Fix Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 6.2.0
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 25 Jul 2021 08:05:28 PM UTC, comment #3: 

Closing report as "won't fix".

Markus Mützel <mmuetzel>
Group administrator
Mon 05 Jul 2021 12:57:29 AM UTC, comment #2: 

I agree with Rik.
The behavior now (version 6.2) is better and more reasonable than before (version 5.2).
Therefore, I think this is an improvement rather than a regression.

Anonymous
Tue 29 Jun 2021 03:58:47 PM UTC, comment #1: 

The behavior of Octave now matches Matlab.  The special index 'end' is supposed to refer to the last element of an array.  If the array does not exist then one interpretation is that a last index can therefore not exist.  This is the position that Matlab takes and which Octave now implements.

A different interpretation would be that the 'end' index should always be valid.  But, it quickly gets complicated.  For example,


clear all
a(end) = 1
b(end+1) = 2


In the first case, 'end' must be set internally equal to 1 by the interpreter so that the variable 'a' is created with one element.

In the second case, should 'end' be equal to 0 or 1.  If it is equal to 0 then 'end+1' = 1 and the variable 'b' will have one element.  However, if 'end' is equal to 1 then the statement will be


b(1+1) = 2
b(2) = 2


and the variable 'b' will have two elements.


Rik <rik5>
Group administrator
Tue 29 Jun 2021 01:09:32 AM UTC, original submission:  

In Octave 5.2.0 it works:

octave:1>  clear all
octave:2>  a(end+1) = 3
a =  3
octave:3>  a(end+1) = 5
a =

   3   5

octave:4>  c{end+1} = 'abcd'
c =
{
  [1,1] = abcd
}

octave:5>  c{end+1} = 1:5
c =
{
  [1,1] = abcd
  [1,2] =

     1   2   3   4   5

}



But in Octave 6.2.0 it fails:

octave:1>  clear all
octave:2>  a(end+1) = 3
error: invalid use of 'end': may only be used to index existing value
octave:3>  c{end+1} = 'abcd'
error: invalid use of 'end': may only be used to index existing value



I'm not sure whether this is a "regression bug" or a "new feature" in Octave 6.2 ?

Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-07-25 mmuetzel StatusNone Wont Fix
        Open/ClosedOpen Closed
    2021-06-29 rik5 CategoryNone Interpreter
        Item GroupRegression Matlab Compatibility
        Operating SystemGNU/Linux Any

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code