bugGNU Octave - Bugs: bug #39735, printf with empty arguments is...


bug #39735: printf with empty arguments is inconsistent with Matlab

Submitted by:  None
Submitted on:  Fri 09 Aug 2013 09:16:14 AM UTC  
Category: Octave FunctionSeverity: 1 - Wish
Priority: 3 - LowItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: Michael LeitnerOriginator Email: -email is unavailable-
Open/Closed: ClosedRelease: dev
Operating System: Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Wed 23 Nov 2016 04:10:27 PM UTC, comment #5:

I checked in the following changeset:


It seems to fix the problem for me so I'm closing this report as fixed.

John W. Eaton <jwe>
Project Administrator
Tue 22 Nov 2016 09:19:10 PM UTC, comment #4:

This behavior is still present in Octave 4.2.0.

Hartmut <hardy>
Thu 04 Jun 2015 01:49:03 AM UTC, comment #3:

Updating release to the development version, still present.

Mike Miller <mtmiller>
Project Administrator
Mon 26 Aug 2013 07:45:23 PM UTC, comment #2:


I can confirm Matlab behaves as you indicated.

Ben Abbott <bpabbott>
Project Member
Fri 09 Aug 2013 01:24:52 PM UTC, comment #1:

Okay, I'm told Matlab does this:

So we should do the same, no matter how stupid it is.

Jordi GutiƩrrez Hermoso <jordigh>
Project Administrator
Fri 09 Aug 2013 09:16:14 AM UTC, original submission:


For me, this is inconsistent behaviour, I would expect the last command to give empty output. It seems that this is connect to the feature of being able to output matrices that "are not exact multiples of the number of conversions in the format template":

Without looking into the code, I cannot imagine the logic leading to these results, for me the most obvious implementation would be to integer-divide the number of supplied elements by the number of conversions in the output string, call C's printf accordingly and special-case the remaining elements (by cutting the output string and pass it once more to C's printf). This would give my expected behaviour. By the way, what does MATLAB do?

At the very least, the observed behaviour is a documentation bug. In 14.2.5 it says "If more than one value is to be printed in a single call, the output functions do not return to the beginning of the format template when moving on from one value to the next. This can lead to confusing output if the number of elements in the matrices are not exact multiples of the number of conversions in the format template." But here it is not more than one value that is to be printed, and also the number of elements is an exact (should say: integer) multiple of the number of output conversions.

Going a step further, I would find an added feature useful: add m and v as type modifier characters, which in the hitherto syntax are being ignored. The output should be:

Initial and trailing spaces/newlines would be left to debate, but I would keep them at a minimum, as the user can supply them in the format string. This could be implemented rather easily by a pass over the output conversion string looking for v or d in a conversion and generating a new string, substituting a %v by the corresponding sequence of %**, given by length(corresponding argument)). Obviously, mixing a %d with a %vd in a single call with both vector arguments would give an awkward situation.



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

Attach File(s):

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 jwe (Posted a comment)
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by bpabbott (Posted a comment)
  • -email is unavailable- added by jordigh (Posted a comment)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 9 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 23 Nov 2016 04:10:27 PM UTCjweStatusConfirmed=>Fixed
    Thu 04 Jun 2015 01:49:03 AM UTCmtmillerSeverity3 - Normal=>1 - Wish
      Priority5 - Normal=>3 - Low
      Operating SystemGNU/Linux=>Any
    Fri 09 Aug 2013 01:25:57 PM UTCjordighItem GroupInaccurate Result=>Matlab Compatibility
      Summaryprintf behaviour is inconsistent for matrix arguments=>printf with empty arguments is inconsistent with Matlab
    Fri 09 Aug 2013 01:24:52 PM UTCjordighStatusNone=>Confirmed

    Back to the top

    Powered by Savane 3.1-cleanup1