diff options
author | David Mitchell <davem@iabyn.com> | 2018-10-17 15:10:10 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2018-10-17 15:10:10 +0100 |
commit | d6139ec4a9065ae249ab512398326a70dfb2fea2 (patch) | |
tree | 308cc34430ba8c3c7e5cd9bd959e8ae7e188957d /pp_hot.c | |
parent | 747c94edea492266c6c728a9dfe08ab31180e02f (diff) | |
download | perl-d6139ec4a9065ae249ab512398326a70dfb2fea2.tar.gz |
fix 'for reverse @array' bug on AIX
RT #133558
Due to what appears to be a compiler bug on AIX (or perhaps it's
undefined behaviour which happens to work on other platforms), this line
of code in pp_iter():
inc = 1 - (PL_op->op_private & OPpITER_REVERSED);
was setting inc to 4294967295 rather than to the expected -1 (inc was a
64-bit signed long).
Fix it with a couple of judicious (IV) casts (which ought to be a NOOP).
Diffstat (limited to 'pp_hot.c')
-rw-r--r-- | pp_hot.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -3932,7 +3932,7 @@ PP(pp_iter) case CXt_LOOP_LIST: /* for (1,2,3) */ assert(OPpITER_REVERSED == 2); /* so inc becomes -1 or 1 */ - inc = 1 - (PL_op->op_private & OPpITER_REVERSED); + inc = (IV)1 - (IV)(PL_op->op_private & OPpITER_REVERSED); ix = (cx->blk_loop.state_u.stack.ix += inc); if (UNLIKELY(inc > 0 ? ix > cx->blk_oldsp @@ -3947,7 +3947,7 @@ PP(pp_iter) case CXt_LOOP_ARY: /* for (@ary) */ av = cx->blk_loop.state_u.ary.ary; - inc = 1 - (PL_op->op_private & OPpITER_REVERSED); + inc = (IV)1 - (IV)(PL_op->op_private & OPpITER_REVERSED); ix = (cx->blk_loop.state_u.ary.ix += inc); if (UNLIKELY(inc > 0 ? ix > AvFILL(av) |