bugGNU Octave - Bugs: bug #65375, stdout is not flushed before...

 
 

bug #65375: stdout is not flushed before message from error()

Submitter:  Rik <rik5>
Submitted:  Tue 27 Feb 2024 04:04:20 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
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
   

Tue 27 Feb 2024 04:04:20 AM UTC, original submission:  

Consider the attached code tst_err_reporting.m


function tst_err_reporting (do_anon = true)
  disp ("Entered function 'tst_err_reporting'");

  subfunction1 (do_anon);

end

function subfunction1 (do_anon)
  disp ("Entered function 'tst_err_reporting>subfunction1'");

  fanon = @(x) x + 1;

  if (do_anon)
    fanon (1, 2);   % Will cause a parse error
  else
    error ("calling error() function from 'subfunction1'");
  end

end


When run in Octave the output is


error: @<anonymous>: function called with too many inputs
error: called from
    subfunction1>@<anonymous>
    tst_err_reporting>subfunction1 at line 14 column 5
    tst_err_reporting at line 4 column 3
Entered function 'tst_err_reporting'
Entered function 'tst_err_reporting>subfunction1'


In Matlab, the strings from disp() are printed on stdout before the final error backtrace.  This seems more logical as the code executes from top to bottom and one would expect the messages to come out in the order in which they were executed.

I think error() should probably be flushing stdout before it proceeds to write to stderr.  There are similarities with bug #63806.

Rik <rik5>
Group administrator

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #55756:  tst_err_reporting.m added by rik5 (386B - 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 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.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-02-27 rik5 Attached File- Added tst_err_reporting.m, #55756

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code