bugGNU Octave - Bugs: bug #41992, inputname fails for arguments...

 
 

bug #41992: inputname fails for arguments stemming from a list

Submitter:  None
Submitted:  Fri 28 Mar 2014 08:29:16 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  bat Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 15 Dec 2016 02:31:50 PM UTC, comment #5: 

Part of this issue is still present in Octave 4.2.0. (But it might be a "WON'T FIX", according to Rik's comment #3.)

This is what I see with Octave 4.2.0 :

  • There are no error messages from inputname any more, when I use the code from commment #0. This has been fixed according to comment #3.
  • I still get different results with Octave when I run the code from comment #1 and compare it to the Matlab result in comment #2. But Rik mentioned in comment #3 that this will maybe never be fixed.



Hartmut <hardy>
Wed 25 Nov 2015 11:50:15 PM UTC, comment #4: 

Can someone test the following in Matlab?


function foo (x)
  inputname (-1)
  inputname (1)
  inputname (2)
end

foo (3)


I'd like to know whether they error out, or silently return an empty string for bad index values.

Rik <rik5>
Group administrator
Wed 25 Nov 2015 11:48:30 PM UTC, comment #3: 

It seems pretty clear that Matlab expands any inputs to a function, such as comma-separated lists, before creating the input argument list.  Octave seems to do the reverse and makes the list of inputs directly from what is available in the parser.

For reference, the code to modify is in ov-usr-fcn.cc.  The function that populates the symbol table is


bind_automatic_vars (arg_names, nargin, nargout, all_va_args (args),
                     lvalue_list);


It is the arg_names variable which is different than expected.

Before this gets fixed, which may never happen, I have re-written inputname so that it at least won't issue strange index out-of-bound errors.  See http://hg.savannah.gnu.org/hgweb/octave/rev/2892f62fb37c.


Rik <rik5>
Group administrator
Tue 01 Apr 2014 02:30:56 PM UTC, comment #2: 

Here is what matlab returns:

ans=
 ''
ans=
 ''
ans=
 ''
ans=
 x


i.e exactly what octave would return after "foo (1,2,3,x)"

Pantxo Diribarne <pantxo>
Group Member
Sat 29 Mar 2014 02:58:15 AM UTC, comment #1: 

Confirmed here as well. I'm not sure if that's the expected behavior, can you test what Matlab does for this example?

Also what would Matlab do with named arguments following a cell array, for example


function foo(varargin)
inputname(1)
inputname(2)
inputname(3)
inputname(4)
end

c = {1,2,3};
x = 12;
foo(c{:},x)


Mike Miller <mtmiller>
Group Member
Fri 28 Mar 2014 08:29:16 PM UTC, original submission:  

I define:

function foo(varargin)
_varval_(".argn.")
nargin
inputname(1)
inputname(2)


If I call foo(5,3), I get the expected behavior where inputname(1) and inputname(2) both evaluate to "".

octave-cli-3.8.1> foo(5,3)
ans =
{
  [1,1] = 5
  [2,1] = 3
}
ans =  2
ans =
ans =

If I define c={5 3} and call foo(c{:}) I expect to get the same thing.  But instead:

octave-cli-3.8.1> c={5 3}; foo(c{:})
ans =
{
  [1,1] = c {:}
}
ans =  2
ans =
error: foo: A(I): index out of bounds; value 2 out of bound 1
error: called from:
error:   /usr/local/share/octave/3.8.1/m/miscellaneous/inputname.m at line 31, column 7


I thought this might be fixed by bug #35497.  Tried incorporating the development version of oct-obj.h.  However, I received same results.

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 hardy (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by mtmiller (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-11-25 rik5 Release3.8.1 dev
    2014-03-29 mtmiller CategoryNone Octave Function
        Item GroupNone Matlab Compatibility
        StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code