bugGNU Octave - Bugs: bug #51785, Inconsistent behavior of various...

 
 

bug #51785: Inconsistent behavior of various shaped empty index vectors in for loops

Submitter:  Geoffrey Adams <biogeo>
Submitted:  Fri 18 Aug 2017 05:52:06 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Duplicate Assigned to:  None
Originator Name:  Geoffrey Adams Open/Closed:  * Closed
Release:  * 4.0.3 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 18 Aug 2017 06:05:44 PM UTC, comment #1: 

Thanks for your bug report. This looks like it covers the same ground as bug #50893, which has already been fixed on the default branch. Indeed your last example does work correctly on Octave's default branch. So this will be working correctly in Octave's 4.4 release.

Mike Miller <mtmiller>
Group Member
Fri 18 Aug 2017 05:52:06 PM UTC, original submission:  

When supplying an empty matrix as the index vector to a for loop, the expected behavior is that the loop body is skipped, as in the following:


for i=[]
    disp('This will never execute');
end


However, for empty matrices that are not shaped as 0-by-0, this is not always the case. In particular, while the following behaves as expected:


for i=reshape([],1,0)
    disp('This will never execute');
end


the following does not:


for i=reshape([],0,1)
    disp('This line executes, and i is a 0-by-1 matrix');
    disp(i);
end


Geoffrey Adams <biogeo>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by biogeo (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-08-18 mtmiller Dependencies- Depends on bugs #50893
    2017-08-18 mtmiller StatusNone Duplicate
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code