Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Thanks for the quick feedback, Corion ... not so sure that you're on the right track, but I certainly can't prove otherwise.

Here's a clearer demo that contains only one instance of "sprintf", and no occurrences of "printf":
use strict; use warnings; use Devel::Peek; use Inline C => Config => BUILD_NOISY => 1, ; use Inline C => <<'EOC'; SV * foo(SV * arg) { SV * keysv; keysv = NEWSV(0, 32); /* Make sure arg is an NV */ if(!SvNOK(arg)) croak("Not a valid arg passed to foo for this demo") +; sv_setpvf(keysv, "%.19" NVgf, SvNV(arg)); return keysv; } SV * bar(SV * arg) { SV * keysv; char buff[30]; keysv = NEWSV(0, 32); /* Make sure arg is an NV */ if(!SvNOK(arg)) croak("Not a valid arg passed to bar for this demo" +); sprintf(buff, "%.19" NVgf, SvNV(arg)); sv_setpvf(keysv, "%s", buff); return keysv; } EOC my $sv_foo = foo(2 ** 63); my $sv_bar = bar(2 ** 63); Dump $sv_foo; print "#####################\n"; Dump $sv_bar;
On Windows 7 it produces (sanely, IMO):
SV = PV(0x72be48) at 0x39bfb8 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x33b748 "9223372036854775808"\0 CUR = 19 LEN = 34 ##################### SV = PV(0x72be98) at 0x33c638 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x33b8d8 "9223372036854775808"\0 CUR = 19 LEN = 34
On Ubuntu-18.04 I see the (insane) output of:
SV = PV(0x56545ac36fd0) at 0x56545ac5b728 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x56545ac57170 "9.2233720368547758e+18"\0 CUR = 22 LEN = 34 ##################### SV = PV(0x56545ac37070) at 0x56545acb8178 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x56545b64be20 "9223372036854775808"\0 CUR = 19 LEN = 34
Interestingly, on Ubuntu, it's the XSub containing the "sprintf" call that's producing the sane result.
(At least, it's producing the output that I expect and want ;-)

Cheers,
Rob

In reply to Re^2: [XS] Weird behaviour on some Linux systems by syphilis
in thread [XS] Weird behaviour on some Linux systems by syphilis

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (6)
    As of 2021-01-26 18:06 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?