This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regexec.c, locale.c: Silence some compiler warnings
authorKarl Williamson <public@khwilliamson.com>
Thu, 6 Feb 2014 16:57:51 +0000 (09:57 -0700)
committerKarl Williamson <public@khwilliamson.com>
Wed, 12 Feb 2014 17:52:57 +0000 (10:52 -0700)
For regexec.c, one compiler amongst our smokers believes there is a path
where this array can be used uninitialized; it's easiest to just
initialize it, even though I think the compiler is wrong, unless it is
optimizing incorrectly, in which case, it would be still be best to
initialize it.

For locale.c, this is just the well-known gcc bug that they refuse to
fix concerning a (void) cast when the function has been declared to
require not ignoring the resul

locale.c
regexec.c

index 8190476..6654468 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -817,7 +817,9 @@ S_is_cur_LC_category_utf8(pTHX_ int category)
          * result */
         if (is_utf8) {
             wchar_t wc;
+            GCC_DIAG_IGNORE(-Wunused-result);
             (void) mbtowc(&wc, NULL, 0);    /* Reset any shift state */
+            GCC_DIAG_RESTORE;
             errno = 0;
             if (mbtowc(&wc, HYPHEN_UTF8, strlen(HYPHEN_UTF8))
                                                         != strlen(HYPHEN_UTF8)
index df8bd14..c4d4ee5 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -3546,7 +3546,7 @@ S_setup_EXACTISH_ST_c1_c2(pTHX_ const regnode * const text_node, int *c1p,
     dVAR;
 
     U8 *pat = (U8*)STRING(text_node);
-    U8 folded[UTF8_MAX_FOLD_CHAR_EXPAND * UTF8_MAXBYTES_CASE + 1];
+    U8 folded[UTF8_MAX_FOLD_CHAR_EXPAND * UTF8_MAXBYTES_CASE + 1] = { '\0' };
 
     if (OP(text_node) == EXACT) {