bugGNU Octave - Bugs: bug #43813, Edge case in indexing rules does...

 
 

bug #43813: Edge case in indexing rules does not work as in Matlab

Submitter:  jose <josombio>
Submitted:  Sat 13 Dec 2014 03:19:12 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  José Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 05 Jun 2015 07:52:28 PM UTC, comment #1: 

I checked in the following changeset:

  http://hg.savannah.gnu.org/hgweb/octave/rev/011a364b4d78

John W. Eaton <jwe>
Group administrator
Sat 13 Dec 2014 03:19:12 PM UTC, original submission:  

There as an edge case in indexing rules that is not handled as in Matlab. This case is not officially documented in Matlab, but unofficially here by SCFrench, an employee from The Mathworks.

According to SCFrench, the rule is (literaly):

When performing subscripted assignment, if

  • subscripted-assigning to an uninitialized variable, AND
  • the uninitialized variable is curly-brace indexed, AND
  • the index in the curly braces is empty, AND
  • the left-hand side appears inside square braces, AND
  • the right-hand side resolves to a value / returns an output

Then the uninitialized variable is assigned a scalar cell  containing the value returned by the right-hand side.

The test: the following code, executed in Matlab

>> clear uninit % just to make sure uninit is uninitialized
>> [uninit{[]}] = sin(0)
uninit =
    [0]

and in Octave 3.8.2

octave:142> clear uninit %
octave:143> [uninit{[]}] = sin(0)
uninit = {}(0x0)


This produces that the following function wrapper

function varargout = wrapper( varargin )
[varargout{1:nargout}] = someFunction( varargin{:} );
endfunction

does not return in Octave a result when the wrapper is called with no output arguments when someFunction returns something even if no output arguments are requested. This is shown in the following code

> [varargout{1:nargout}] = sin( varargin{:} );
> endfunction
octave:76> wrapper(0) %this should give ans = 0, and it does not.
octave:77> a=wrapper(0)
a = 0
octave:78> sin(0)
ans = 0


jose <josombio>

 

(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 jwe (Posted a comment)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by josombio (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-09-12 mtmiller StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2015-06-05 jwe StatusConfirmed Ready For Test
    2015-06-05 mtmiller StatusNone Confirmed
        Release3.8.2 dev
        Operating SystemGNU/Linux Any

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code