bugGNU Octave - Bugs: bug #64057, assert.m: struct comparison skips...

 
 

bug #64057: assert.m: struct comparison skips type checking for field values

Submitter:  Pantxo Diribarne <pantxo>
Submitted:  Sun 16 Apr 2023 07:49:02 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Missed Error or Warning
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * 8.1.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 01 May 2023 07:21:27 PM UTC, comment #2: 

My concern is that two bare variables that compare false in a base context, due to type inconsistency, compare true when they are embedded in a struct.


assert (1, single (1)) ## -> error,  double != single
assert (struct ("num", 1), struct ("num", single (1))) ## -> ok, while value types are still wrong


Again, this may be expected (e.g. for performance when traversing deeply nested structures) but I just wanted to report it. At least now I know if I care about type checking in structs, I should traverse all fields myself.
 

Pantxo Diribarne <pantxo>
Group Member
Sun 30 Apr 2023 12:28:55 AM UTC, comment #1: 

Does not seem to be a problem; true and logical 1 are compared to be equal - it makes sense to remain this way.

Whereas, as expected, true and false are unequal.

If you want the GTEST type checking with equivalence you can propose a new function IMHO

MA <anyee>
Sun 16 Apr 2023 07:49:02 PM UTC, original submission:  

I don't know if this is the expected behavior: `assert` correctly compares struct fields values but skips type checking. E.g the followings structs


a.logical = true;
b.logical = false;
c.logical = 1;


are sometimes mistakenly considered equal


octave:11> assert (a, b)
error: ASSERT errors for:  assert (cond {i},expected {i},tol)

  Location  |  Observed  |  Expected  |  Reason
     ()           1            0         Abs err 1 exceeds tol 0 by 1
octave:12> assert (a, c)
octave:13> assert (a.logical, c.logical)
error: ASSERT errors for:  assert (a.logical,c.logical)

  Location  |  Observed  |  Expected  |  Reason
     ()           O            E         Class logical != double


Pantxo Diribarne <pantxo>
Group Member

 

(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 anyee (Posted a comment)
  • -email is unavailable- added by pantxo (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.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code