diff mbox

[libgfortran,committed] Fix -Wmaybe-uninitialized warnings

Message ID CAO9iq9FFksTxnL7qt1r+cui1WtiRPAko_so36JtCODgmX9kUpQ@mail.gmail.com
State New
Headers show

Commit Message

Janne Blomqvist Sept. 30, 2014, 9:18 p.m. UTC
Hi,

I compiled libgfortran with -Werror, and fixed the fallout with the
attached patch. Committed r215742 as obvious.

2014-10-01  Janne Blomqvist  <jb@gcc.gnu.org>

    * intrinsics/pack_generic.c (pack_s_internal): Fix
    -Wmaybe-uninitialized warning.
    * m4/unpack.m4 (unpack0_'rtype_code`): Likewise.
    (unpack1_'rtype_code`): Likewise.
    * generated/unpack_*.m4: Regenerated.
diff mbox

Patch

diff --git a/libgfortran/intrinsics/pack_generic.c b/libgfortran/intrinsics/pack_generic.c
index 3fbfa0a..831f396 100644
--- a/libgfortran/intrinsics/pack_generic.c
+++ b/libgfortran/intrinsics/pack_generic.c
@@ -463,6 +463,9 @@  pack_s_internal (gfc_array_char *ret, const gfc_array_char *array,
   index_type total;
 
   dim = GFC_DESCRIPTOR_RANK (array);
+  /* Initialize sstride[0] to avoid -Wmaybe-uninitialized
+     complaints.  */
+  sstride[0] = size;
   ssize = 1;
   for (n = 0; n < dim; n++)
     {
diff --git a/libgfortran/m4/unpack.m4 b/libgfortran/m4/unpack.m4
index e945446..271eae2 100644
--- a/libgfortran/m4/unpack.m4
+++ b/libgfortran/m4/unpack.m4
@@ -105,6 +105,8 @@  unpack0_'rtype_code` ('rtype` *ret, const 'rtype` *vector,
   else
     {
       dim = GFC_DESCRIPTOR_RANK (ret);
+      /* Initialize to avoid -Wmaybe-uninitialized complaints.  */
+      rstride[0] = 1;
       for (n = 0; n < dim; n++)
 	{
 	  count[n] = 0;
@@ -250,6 +252,8 @@  unpack1_'rtype_code` ('rtype` *ret, const 'rtype` *vector,
   else
     {
       dim = GFC_DESCRIPTOR_RANK (ret);
+      /* Initialize to avoid -Wmaybe-uninitialized complaints.  */
+      rstride[0] = 1;
       for (n = 0; n < dim; n++)
 	{
 	  count[n] = 0;