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

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

[Octave-bug-tracker] [bug #55810] sizeof() returns 0 for classdef object


From: Andrew Janke
Subject: [Octave-bug-tracker] [bug #55810] sizeof() returns 0 for classdef objects
Date: Sat, 2 Mar 2019 08:27:49 -0500 (EST)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36

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

                 Summary: sizeof() returns 0 for classdef objects
                 Project: GNU Octave
            Submitted by: apjanke
            Submitted on: Sat 02 Mar 2019 01:27:48 PM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.4.1
        Operating System: Mac OS

    _______________________________________________________

Details:

It looks like the default implementation of sizeof() returns 0 for
user-defined classdef objects. (I think this also causes the Bytes for
classdef objects in the `whos` output to be displayed as 0.)

IMHO, it would make more sense for the default implementation of sizeof() to 
do a `builtin('struct', x)` on user-defined objects and return that. That
would give you a decent approximation of the Octave-managed raw data being
used by those objects.

To reproduce:

Define MyDumbClass.m:


classdef MyDumbClass

  properties
    data
  endproperties

  methods
    function this = MyDumbClass (data)
      this.data = data;
    endfunction
  endmethods

endclassdef


Create one and check its size:


>> x = MyDumbClass(zeros(1000, 1000))
x =
<object MyDumbClass>

>> sizeof(x)
ans = 0
>> sizeof(x.data)
ans =  8000000


I think that sizeof(x) should be returning 8000000 instead of 0.





    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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