bugGNU Octave - Bugs: bug #55758, classdef: delete method causes...


bug #55758: classdef: delete method causes temporaries to be deleted before use

Submitted by:  Mike Miller <mtmiller>
Submitted on:  Thu 21 Feb 2019 11:16:30 PM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  dev Operating System:  GNU/Linux

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Wed 17 Apr 2019 06:06:14 PM UTC, comment #4: 

OK, closing as fixed.

John W. Eaton <jwe>
Project Administrator
Tue 09 Apr 2019 03:12:38 AM UTC, comment #3: 

Ok, may be an issue in my code, this might be fixed. You can close it as fixed if you want and I can come back later if there is still a problem. It will take a little refactoring.

Basically, I have a constructor that depends on values initialized in C++ code. The C++ function returns a second instance of the object, which overwrites the original.

classdef myobject < handle
    function obj = myobject (value, id)
      if (nargin == 1)
        obj = __helper_function__ (value);
        obj.id = id;

This created two instances of the object, and when the first one was deleted, it hadn't been fully constructed, so it looked like properties of the object were missing. I'll rewrite all of this so a second instance of the object doesn't need to be created.

Mike Miller <mtmiller>
Project Administrator
Tue 09 Apr 2019 12:37:13 AM UTC, comment #2: 

Something still does not work for me, I'll try to come back with a minimal example that demonstrates the remaining errors I'm seeing.

Mike Miller <mtmiller>
Project Administrator
Fri 15 Mar 2019 07:30:27 PM UTC, comment #1: 

I pushed the following changset:


In it, I added tests based on what you show below and they are passing for me now.

John W. Eaton <jwe>
Project Administrator
Thu 21 Feb 2019 11:16:30 PM UTC, original submission:  

Attached is a classdef handle class example with a delete method. With this example class, the following shows that temporary objects are deleted by the interpreter before they are passed into the functions that they are arguments for.

>> class_delete_method (5).value
>> class_delete_method (5)(1)
>> disp (class_delete_method (5))
<object class_delete_method>
>> size (class_delete_method (5))
>> numel (class_delete_method (5))

The 'delete' destructor is called properly, it does have access to the class properties when it is deleted, but the object is deleted by the interpreter before it is placed on the call stack.

Removing the 'delete' method from the class definition restores the normal behavior of how I would expect temporaries to work.

Because of the major rework of the call stack on the default branch recently, I figured this would be a good candidate for fixing for Octave 6.

I also think the attached class is a good start for some BIST tests for the delete method.

This was originally discussed in comments on bug #53844, so marking as confirmed.

Mike Miller <mtmiller>
Project Administrator


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

Attach Files:

Attached Files
file #46331:  class_delete_method.m added by mtmiller (535B - text/x-objcsrc)


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)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-04-17 jwe StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
    2019-03-15 jwe StatusConfirmed => Ready For Test
    2019-02-21 mtmiller Carbon-CopyRemoved 80942 => -
    2019-02-21 mtmiller Attached File- => Added class_delete_method.m, #46331

    Back to the top

    Powered by Savane 3.5