Skip to content

Storing difference of pointers in I32 #20841

@hvds

Description

@hvds

As mentioned in perlmonks, we have this concept repeatedly in inline.h (eg line 2951 in blead at dab4006):

    PL_curstackinfo->si_cxsubix = cx - PL_curstackinfo->si_cxstack;

PL_curstackinfo->si_cxsubix is declared as I32 (in cop.h as part of struct stackinfo), so at first glance this appears to be unsafe when we have 64-bit pointers. I don't know if this just needs a cast (possibly with overflow checks), or whether si_cxsubix and its old_cxsubix derivatives need to be a different type such as ptrdiff_t.

The perlmonks report complains that this results in many warnings when building with MSVC on an appropriate platform; it isn't clear to me why gcc doesn't complain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions