bugGNU Octave - Bugs: bug #51784, mexGetVariable does returns empty...

 
 

bug #51784: mexGetVariable does returns empty matrix instead of nullptr for non-existant global variables

Submitter:  Piotr Held <jsoh425>
Submitted:  Fri 18 Aug 2017 05:30:39 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Works For Me Assigned to:  None
Originator Name:  Piotr Held Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 23 Aug 2017 11:14:47 PM UTC, comment #3: 

I'm sorry for the hassle. I downloaded a fresh new version from the repo and you're right, it does work. I don't know why it didn't work on a previous build of mine (the code seems to be the same in the crucial parts). You can close this bug.

Piotr Held <jsoh425>
Wed 23 Aug 2017 10:19:04 PM UTC, comment #2: 

This works for me already without the patch.  Could you verify that this is really necessary?  There is a quirk in that run-octave doesn't work for testing.  You need to install a version to some location like ~/local and execute that copy of Octave.

I've attached a file mygetv.c.  Try


clear all
mex mygetv.c
mygetv ("global", "a")
x = mygetv ("global", "a")


In neither case is the empty matrix [] returned even though the variable "a" does not exist.


(file #41633)

Rik <rik5>
Group administrator
Wed 23 Aug 2017 04:05:19 PM UTC, comment #1: 

The mex api call that I am referring to looks like this:


mexGetVariable("global", "SOME_GLOBAL_VARIABLE");


If SOME_GLOBAL_VARIABLE doesn't exist GNU Octave currently returns a null matrix (zeros(0,0)), and according to Matlab documentation and Matlab behavior mexGetVariable should return nullptr in such a case.

Piotr Held <jsoh425>
Fri 18 Aug 2017 05:30:39 PM UTC, original submission:  

I double checked this with Matlab (and their documentation) and the way it's suppose to work is that if the global variable doesn't exist mexGetVariable should return nullptr. Currently it returns an empty matrix.

I am attaching patch to fix this problem.

Piotr Held <jsoh425>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #41633:  mygetv.c added by rik5 (489B - text/x-csrc)
file #41571:  patch_mexGetVariable.diff added by jsoh425 (909B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by jsoh425 (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
    2017-08-24 rik5 StatusNeed Info Works For Me
        Open/ClosedOpen Closed
    2017-08-23 rik5 Attached File- Added mygetv.c, #41633
        StatusNone Need Info
    2017-08-18 jsoh425 Attached File- Added patch_mexGetVariable.diff, #41571

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code