bugGNU Octave - Bugs: bug #57615, assert() fails on input which was...

 
 

bug #57615: assert() fails on input which was valid in version 5.1

Submitter:  Rik <rik5>
Submitted:  Fri 17 Jan 2020 12:01:51 AM UTC
   
 
Category:  Octave Function Severity:  4 - Important
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 17 Jan 2020 04:44:38 AM UTC, comment #1: 

Fixed in this chanegset https://hg.savannah.gnu.org/hgweb/octave/rev/70576ed5cc42.


Closing report.

Rik <rik5>
Group administrator
Fri 17 Jan 2020 12:01:51 AM UTC, original submission:  

Sample code:


assert (complex (pi*1e-17,2*pi), 0, 1e-1)
error: sprintf: invalid field width, must be integer >= 0 and <= INT_MAX
error: called from
    assert>pprint at line 705 column 9
    assert at line 419 column 16


However, in 5.1 the result is correct


assert (complex (pi*1e-17,2*pi), 0, 1e-1)
error: ASSERT errors for:  assert (complex (pi * 1e-17, 2 * pi),0,1e-1)

  Location  |  Observed  |  Expected  |  Reason
     ()      3.1416e-17+6.2832i      0         Abs err 6.2832 exceeds tol 0.1 by 6


The problem code is in assert.m


  str = ["ASSERT errors for:  assert " argin "\n"];
  str = [str, "\n  Location  |  Observed  |  Expected  |  Reason\n"];
  for i = 1:length (err.index)
    leni = length (err.index{i});
    leno = length (err.observed{i});
    lene = length (err.expected{i});
    str = [str, sprintf("%*s%*s %*s%*s %*s%*s   %s\n",
                        6+fix(leni/2), err.index{i}   , 6-fix(leni/2), "",
                        6+fix(leno/2), err.observed{i}, 6-fix(leno/2), "",
                        6+fix(lene/2), err.expected{i}, 6-fix(lene/2), "",
                        err.reason{i})];


Trouble is that 6 - XXX may go below zero, as it does here, if the length of the field is large.

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 (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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-01-17 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code