in reply to SvUV vs SvIV for pointers in SVs, typemap

shouldn't pointers be SvUV not SvIV?

On 32-bit OSs they certainly should be. Whilst out-of-the-box, 32-bit OSs only provide user space programs with access to the lower 2GB of ram; most if not all of them can push that upto 3GB with the appropriate build or start-up options.

And at that point using signed math on pointers could render incorrect results.


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.
  • Comment on Re: SvUV vs SvIV for pointers in SVs, typemap

Replies are listed 'Best First'.
Re^2: SvUV vs SvIV for pointers in SVs, typemap
by ikegami (Patriarch) on Feb 20, 2011 at 20:53 UTC

    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
      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.