From 5eabe374afae7b84aa4ba5e13e5424865bc74fc1 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Tue, 12 Dec 2017 23:01:02 -0700 Subject: [PATCH] inline.h: Fix wrong order of shift and mask I realized that one should mask before the shift in this macro that is used in is_utf8_invariant_string_loc() and variant_under_utf8_count(). This would only show up on a 32-bit platform that doesn't have 64-bit ability at all. --- inline.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inline.h b/inline.h index 28bc1f5..af26cf5 100644 --- a/inline.h +++ b/inline.h @@ -400,10 +400,10 @@ S_is_utf8_invariant_string_loc(const U8* const s, STRLEN len, const U8 ** ep) * or'ing together the lowest bits of 'x'. Hopefully the final term gets * optimized out completely on a 32-bit system, and its mask gets optimized out * on a 64-bit system */ -#define PERL_IS_SUBWORD_ADDR(x) (1 & ( PTR2nat(x) \ - | (PTR2nat(x) >> 1) \ - | ( (PTR2nat(x) >> 2) \ - & PERL_WORD_BOUNDARY_MASK))) +#define PERL_IS_SUBWORD_ADDR(x) (1 & ( PTR2nat(x) \ + | ( PTR2nat(x) >> 1) \ + | ( ( (PTR2nat(x) \ + & PERL_WORD_BOUNDARY_MASK) >> 2)))) /* Do the word-at-a-time iff there is at least one usable full word. That * means that after advancing to a word boundary, there still is at least a -- 1.8.3.1