bugGNU Octave - Bugs: bug #64419, isequal fails for old-style...

 
 

bug #64419: isequal fails for old-style @audioplayer, @audiorecorder objects

Submitter:  Rik <rik5>
Submitted:  Wed 12 Jul 2023 06:38:52 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  3 - Low Item Group:  Unexpected Error or Warning
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 14 Jul 2023 12:26:28 AM UTC, comment #2: 

Well, the cause of this is peculiar to the coding of @audioplayer and @audiorecorder.  Instead of storing property names and values in a struct which is then made into an object with class(), the constructor for these objects creates a struct with a single field which is effectively a pointer to a C++ object.  Hence, calling struct() on the object does return the correct thing.  However, unlike the @ftp class which does something similar in storing a pointer, the audioplayer classes store something that always looks like 0 when displayed and is probably something like a C++ octave_class value.

I don't care to debug this further.

Rik <rik5>
Group administrator
Thu 13 Jul 2023 12:56:20 AM UTC, comment #1: 

The issue is traceable to the way isequal handles objects.  The function uses


s = builtin ("struct", obj);


to convert an object to a struct.  For classdef objects this returns a struct where all properties (including read-only, etc.) are fieldnames along with their value.

However, for old-style class objects this seems to return a confused struct object which, when indexed, reverts back to a class object.


octave:2> a = audiorecorder ();
octave:3> typeinfo (a)
ans = class
octave:4> class (a)
ans = audiorecorder
octave:5> s = builtin ("struct", a)
s =

  scalar structure containing the fields:

    recorder = 0

octave:7> typeinfo (s)
ans = scalar struct
octave:8> class (s)
ans = struct
octave:9> y = s.recorder
error: struct: additional arguments must occur as "field", VALUE pairs
error: called from
    __get_properties__ at line 36 column 13
    disp at line 35 column 3
y = audiorecorder object with properties:

octave:10> typeinfo (y)
ans = audiorecorder
octave:11> class (y)
ans = audiorecorder


I think the issue needs to be resolved in struct().  Given that the call


obj = class (STRUCT, "classname")


creates an old-style class object, it should be relatively easy to revert back to a struct.

Adding jwe to the CC list because this is plain-old weird.

Rik <rik5>
Group administrator
Wed 12 Jul 2023 06:38:52 PM UTC, original submission:  

Code to reproduce:


octave:2> r = audiorecorder ();
octave:3> r2 = r;
octave:4> isequal (r, r2)
error: isequal: Impossible to reach code.  File a bug report.
error: called from
    isequal at line 182 column 9
    isequal at line 137 column 18


Per Octave's instructions, I'm filing a bug report.

Note that new-style classdef objects do work.


octave:7> m = containers.Map ();
octave:8> m2 = m;
octave:9> isequal (m, m2)
ans = 1


Apparently this has been present for a very long time because I went and tried Octave-4.4.1 and it has the same error.

Rik <rik5>
Group administrator

 

(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 rik5
  • -email is unavailable- added by rik5 (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-07-14 rik5 Priority5 - Normal 3 - Low
        Summaryisequal fails for old-style @class objects isequal fails for old-style @audioplayer, @audiorecorder objects
    2023-07-13 rik5 Carbon-Copy- Added jwe

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code