This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
inline.h: Fix wrong order of shift and mask
authorKarl Williamson <khw@cpan.org>
Wed, 13 Dec 2017 06:01:02 +0000 (23:01 -0700)
committerKarl Williamson <khw@cpan.org>
Wed, 13 Dec 2017 06:19:37 +0000 (23:19 -0700)
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

index 28bc1f5..af26cf5 100644 (file)
--- 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