in reply to Re: SvUV vs SvIV for pointers in SVs, typemap
in thread SvUV vs SvIV for pointers in SVs, typemap

If you cast the pointer to some int type, pointer arithmetic will be wrong whether it's signed or not.

use Inline C => <<'__EOI__'; int test() { SV* sv = &PL_sv_undef; printf("%p\n", sv+2); printf("%p\n", ((IV)sv)+2); printf("%p\n", ((UV)sv)+2); } __EOI__ test();
0x746310 0x7462e2 0x7462e2

Replies are listed 'Best First'.
Re^3: SvUV vs SvIV for pointers in SVs, typemap
by BrowserUk (Patriarch) on Feb 20, 2011 at 21:26 UTC
    If you cast the pointer to some int type,

    And if you clean your windscreen with a hammer, you'll not like the results either.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      I disagree. One just needs to cast it back to a pointer before using it. The typemap does this.
        One just needs to cast it back to a pointer before using it.

        This assumes that "one" is writing the code that is manipulating the pointers that are stored in, and manipulated as, SvIVs.

        Have you tried running Perl on a 32-bit system configured for /3GB?

        See also Re: Memory usage in Perl on Windows systems.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.