Using the following code produces different results in 5.6.1 and 5.8.0 (compiled with the same compiler version and the same flags except that 5.8.0 was compiled with ithreads):
# file: printf.pl printf "%4.4f\n", 3.14159; printf "%4.4lf\n", 3.14159; printf "%4.4hf\n", 3.14159; printf "%4.4qf\n", 3.14159; printf "%4.4Lf\n", 3.14159; printf "%4.4llf\n", 3.14159;

Results:

$ /usr/bin/perl5.6.1 printf.pl 3.1416 3.1416 3.1416 %4.4qf %4.4Lf %4.4llf $ /usr/local/bin/perl5.8.0 printf.pl 3.1416 %4.4lf %4.4hf %4.4qf 3.1416 3.1416

As it turns out, none of these printf size flags are tested in either 5.6.1 or 5.8.0 core tests. The relevant config details for each version are the same (snipped for brevity):

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuratio +n: use64bitint=undef use64bitall=undef uselongdouble=undef intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=8 alignbytes=4, usemymalloc=n, prototype=define Summary of my perl5 (revision 5.0 version 8 subversion 0) configuratio +n: use64bitint=undef use64bitall=undef uselongdouble=undef intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=8 alignbytes=4, prototype=define

This was noticed when installing Text::Reform with 5.8.0, the module has a single case of using sprintf with an 'lf' (at line 141) which passes all tests on my 5.6.1 but fails on my 5.8.0. My questions: is it at all wise to use these size flags? Is this a perl bug not detected because it isn't tested for? Shouldn't the size flags (l,h,q,L,and ll) simply be ignored if unsupported on a given platform? (platform is linux)


In reply to printf size flag incompatibility by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.