Skip to content

EXTEND_HWM_SET() should not declare "ix" #19818

@hvds

Description

@hvds

We need to be a lot more careful in macros to avoid using variable names likely to appear in the interpolated arguments. See https://perlmonks.org/?node_id=11144355 for an example, which I reckon was unreasonably hard to debug:

                EXTEND(SP, ix == 3 ? 2*n : n);

I've no idea what the compiler is actually trying to do with this in:

#  define EXTEND_HWM_SET(p, n)                      \
        STMT_START {                                \
            SSize_t ix = (p) - PL_stack_base + (n); \
            if (ix > PL_curstackinfo->si_stack_hwm) \
                PL_curstackinfo->si_stack_hwm = ix; \
        } STMT_END
#  define EXTEND(p,n)   STMT_START {                                    \
                         EXTEND_HWM_SET(p, n);                          \
                         if (UNLIKELY(_EXTEND_NEEDS_GROW(p,n))) {       \
                           sp = stack_grow(sp,p,_EXTEND_SAFE_N(n));     \
                           PERL_UNUSED_VAR(sp);                         \
                         } } STMT_END

but I suspect we're in nasal demon territory.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions