This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Pass a UV to a format expecting a UV
authorTony Cook <tony@develop-help.com>
Wed, 28 Nov 2018 23:50:19 +0000 (23:50 +0000)
committerTony Cook <tony@develop-help.com>
Thu, 29 Nov 2018 00:40:22 +0000 (11:40 +1100)
MAX_LEGAL_CP can end up as int depending on the ranges of the types
involved, causing a type mismatch on the format in cp_above_legal_max.

By adding the cast to the macro definition we both prevent the type
mismatch on the format, but also may allow some static analysis tool to
detect comparisons against signed types, which is likely an error.

utf8.h

diff --git a/utf8.h b/utf8.h
index 6759a54..57be2e4 100644 (file)
--- a/utf8.h
+++ b/utf8.h
@@ -758,7 +758,7 @@ point's representation.
 
 #define UTF8_IS_REPLACEMENT(s, send) is_REPLACEMENT_utf8_safe(s,send)
 
-#define MAX_LEGAL_CP  IV_MAX
+#define MAX_LEGAL_CP  ((UV)IV_MAX)
 
 /*
 =for apidoc Am|bool|UTF8_IS_SUPER|const U8 *s|const U8 *e