octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #54799] MEX: creating scalar struct with no fi


From: Amro
Subject: [Octave-bug-tracker] [bug #54799] MEX: creating scalar struct with no fields using mxCreateStructMatrix
Date: Sun, 7 Oct 2018 04:26:01 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0

URL:
  <https://savannah.gnu.org/bugs/?54799>

                 Summary: MEX: creating scalar struct with no fields using
mxCreateStructMatrix
                 Project: GNU Octave
            Submitted by: amro_octave
            Submitted on: Sun 07 Oct 2018 11:25:59 AM EEST
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.4.1
        Operating System: Any

    _______________________________________________________

Details:

Consider the following MEX-function:

scalar_struct_no_fields.c


#include "mex.h"
void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    if (nlhs > 1)
        mexErrMsgIdAndTxt("mex:error", "Wrong number of arguments");
    plhs[0] = mxCreateStructMatrix(1, 1, 0, NULL);
}


Basically it's supposed to create a 1x1 scalar structure with no fields,
however it returns an empty 0x0 struct.

Tested in Octave 4.4.1-w64 on Windows:


>> s1 = struct()
s1 =
  scalar structure containing the fields:

>> s2 = scalar_struct_no_fields()
s2 =
  0x0 struct array containing the fields:


>> assert(isequal(s1,s2))
error: assert (isequal (s1, s2)) failed
error: called from
    assert at line 92 column 11
>> whos s1 s2
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
        s1          1x1                          0  struct
        s2          0x0                          0  struct

Total is 1 element using 0 bytes


The same tested in MATLAB R2018a:


>> s1 = struct()
s1 = 
  struct with no fields.
>> s2 = scalar_struct_no_fields()
s2 = 
  struct with no fields.
>> assert(isequal(s1,s2))
>> whos s1 s2
  Name      Size            Bytes  Class     Attributes

  s1        1x1                 0  struct              
  s2        1x1                 0  struct              
          






    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?54799>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]