bugGNU Octave - Bugs: bug #41091, fread's second outarg is number of...


bug #41091: fread's second outarg is number of bytes read, not elements as required

Submitted by:  Philipp Kutin <pkutin>
Submitted on:  Fri 03 Jan 2014 08:34:25 PM UTC  
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  John W. Eaton <jwe>
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.


Fri 03 Jan 2014 11:00:33 PM UTC, comment #4: 

This works for me with the reporter's original file and with some tests of my own.  Closing report.

Rik <rik5>
Project Administrator
Fri 03 Jan 2014 10:31:37 PM UTC, comment #3: 

I checked in the following change on the stable branch:


Please close this report if this change fixes the problem and doesn't appear to introduce any new problems.

John W. Eaton <jwe>
Project AdministratorIn charge of this item.
Fri 03 Jan 2014 09:33:23 PM UTC, comment #2: 

I'm looking at it now.

John W. Eaton <jwe>
Project AdministratorIn charge of this item.
Fri 03 Jan 2014 08:44:31 PM UTC, comment #1: 

It is a regression.  Both 3.4.3 and 3.6.4 correctly return the number of elements.  Changing the item group to "Regression".

Rik <rik5>
Project Administrator
Fri 03 Jan 2014 08:34:25 PM UTC, original submission:  

On a file 'sevenbytes.bin', the following script,

fid = fopen('sevenbytes.bin');
assert(fid >= 0);

[a, cnt] = fread(fid, 3, 'int16');  % should read enough
if (numel(a) ~= 3)
    fprintf('Failed reading 3 16-bit ints\n');
elseif (cnt ~= 3)
    fprintf('Expected cnt==3, got %d\n', cnt);

[b, cnt] = fread(fid, 2, 'int16');  % don't have enough data
fprintf('numel(b): %d\n', numel(b));
fprintf('cnt: %d\n', cnt);



% MATLAB R2013a
>> fread_second_outarg
numel(b): 0
cnt: 0

% Octave default
octave:1> fread_second_outarg
Expected cnt==3, got 6
numel(b): 2
cnt: 1

Beisdes being a MATLAB incompatibility, I'm pretty sure that it's an Octave regression too.

Philipp Kutin <pkutin>


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

Attach Files:

Attached Files
file #30178:  sevenbytes.bin added by pkutin (7B - application/octet-stream)
file #30179:  fread_second_outarg.m added by pkutin (382B - application/vnd.wolfram.mathematica.package)
file #30180:  fread_second_outarg.log added by pkutin (156B - text/x-log)


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)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by pkutin (Submitted the item)

    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 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-01-03 rik5 StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
    2014-01-03 jwe StatusConfirmed => Ready For Test
    2014-01-03 jwe Assigned toNone => jwe
    2014-01-03 rik5 StatusNone => Confirmed
    2014-01-03 rik5 Item GroupMatlab Compatibility => Regression
    2014-01-03 pkutin Attached File- => Added sevenbytes.bin, #30178
        Attached File- => Added fread_second_outarg.m, #30179
        Attached File- => Added fread_second_outarg.log, #30180

    Back to the top

    Powered by Savane 3.5