bugGNU Octave - Bugs: bug #56006, Object indexing:...

 
 

bug #56006: Object indexing: obj(1).property(end+1:n) - end is interpreted wrong

Submitter:  Andrew Janke <apjanke>
Submitted:  Wed 27 Mar 2019 02:21:41 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Mac OS
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 17 Apr 2023 11:14:23 AM UTC, comment #3: 

Thank you for testing.

I don't see how this particular example would behave differently depending on the platform. So, I'm going to close this as fixed. Even if we don't know in which particular version this was fixed, it seems to be working in Octave 8 according to comment #2.

It can be re-opened if this should still be an issue.

Markus Mützel <mmuetzel>
Group administrator
Mon 17 Apr 2023 09:02:32 AM UTC, comment #2: 

At least, it works for me in Linux Mint 21.1. I cannot try it in Mac OS.

Fernando <tutissanalio>
Mon 17 Apr 2023 08:59:03 AM UTC, comment #1: 

This works now, both in stable and default.

Fernando <tutissanalio>
Wed 27 Mar 2019 02:21:41 AM UTC, original submission:  

I'm running into a weird indexing issue.

Let's say I have a class Version, that represents software versions.


classdef Version
  properties
    elements = [0]
  endproperties
  methods
    function this = Version (elements)
      if nargin == 0
        return
      endif
      this.elements = elements;
    endfunction
    function disp (this)
      fprintf ("Version: %s\n", mat2str(this.elements));
    endfunction
  endmethods
endclassdef


I have a 3-element Version that I want to pad out with zeros to be six elements. If it is a scalar Version object and I address it as such, this works fine.


octave:16> v = Version([3 3 3])
v =
Version: [3 3 3]

octave:17> v.elements(end+1:6) = 0
v =
Version: [3 3 3 0 0 0]


But if I have an array of Version objects and I index them individually before addressing their property, the wrong elements get overwritten.


octave:19> v = Version([3 3 3])
v =
Version: [3 3 3]

octave:20> v(1).elements(end+1:6) = 0
v =
Version: [3 0 0 0 0 0]

octave:21>


It seems like in this case, the `end` is being interpreted with respect to the size of v or v(1), not the size of v(1).elements (which I think it should be).

Happens in 4.4.1, 5.1.0, and default.

Andrew Janke <apjanke>

 

(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 tutissanalio (Posted a comment)
  • -email is unavailable- added by apjanke (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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-04-17 mmuetzel StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code