Fix may be uninitialized warnings in libgfortran
Andreas Jaeger
aj@suse.de
Sun May 15 12:40:00 GMT 2005
We get a number of these warnings in libgfortran:
/cvs/gcc/libgfortran/generated/eoshift1_4.c:73: warning: ‘len’ may be used uninitialized in this function
All of them look like false positives but the algorithm is written in
a way that the compiler cannot catch it. I propose to initialize the
warnings - this is AFAIK the same way we do in the rest of the
compiler.
Ok to commit the appended patch?
Tested on Linux/x86-64.
Andreas
* m4/eoshift1.m4: Initialize variables to avoid warnings.
* m4/eoshift3.m4: Initialize variables to avoid warnings.
* generated/eoshift1_4.c, generated/eoshift1_8.c,
generated/eoshift3_4.c, generated/eoshift3_8.c: Regenerated.
* intrinsics/spread_generic.c (spread): Initialize variables to
avoid warnings.
* intrinsics/eoshift0.c (eoshift0): Initialize variables to avoid
warnings.
* io/list_read.c (nml_get_obj_data): Initialize variables to avoid
warnings.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050515/07345783/attachment.sig>
-------------- next part --------------
============================================================
Index: libgfortran/generated/eoshift1_4.c
--- generated/eoshift1_4.c 4 May 2005 21:38:15 -0000 1.6
+++ generated/eoshift1_4.c 15 May 2005 12:38:45 -0000
@@ -1,5 +1,5 @@
/* Implementation of the EOSHIFT intrinsic
- Copyright 2002 Free Software Foundation, Inc.
+ Copyright 2002, 2005 Free Software Foundation, Inc.
Contributed by Paul Brook <paul@nowt.org>
This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -76,6 +76,12 @@ eoshift1_4 (const gfc_array_char *ret,
GFC_INTEGER_4 sh;
GFC_INTEGER_4 delta;
+ /* The compiler cannot figure out that these are set, initialize
+ them to avoid warnings. */
+ len = 0;
+ soffset = 0;
+ roffset = 0;
+
if (pwhich)
which = *pwhich - 1;
else
============================================================
Index: libgfortran/generated/eoshift1_8.c
--- generated/eoshift1_8.c 4 May 2005 21:38:15 -0000 1.6
+++ generated/eoshift1_8.c 15 May 2005 12:38:45 -0000
@@ -1,5 +1,5 @@
/* Implementation of the EOSHIFT intrinsic
- Copyright 2002 Free Software Foundation, Inc.
+ Copyright 2002, 2005 Free Software Foundation, Inc.
Contributed by Paul Brook <paul@nowt.org>
This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -76,6 +76,12 @@ eoshift1_8 (const gfc_array_char *ret,
GFC_INTEGER_8 sh;
GFC_INTEGER_8 delta;
+ /* The compiler cannot figure out that these are set, initialize
+ them to avoid warnings. */
+ len = 0;
+ soffset = 0;
+ roffset = 0;
+
if (pwhich)
which = *pwhich - 1;
else
============================================================
Index: libgfortran/generated/eoshift3_4.c
--- generated/eoshift3_4.c 4 May 2005 21:38:16 -0000 1.6
+++ generated/eoshift3_4.c 15 May 2005 12:38:45 -0000
@@ -1,5 +1,5 @@
/* Implementation of the EOSHIFT intrinsic
- Copyright 2002 Free Software Foundation, Inc.
+ Copyright 2002, 2005 Free Software Foundation, Inc.
Contributed by Paul Brook <paul@nowt.org>
This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -78,6 +78,12 @@ eoshift3_4 (gfc_array_char *ret, gfc_arr
GFC_INTEGER_4 sh;
GFC_INTEGER_4 delta;
+ /* The compiler cannot figure out that these are set, initialize
+ them to avoid warnings. */
+ len = 0;
+ soffset = 0;
+ roffset = 0;
+
if (pwhich)
which = *pwhich - 1;
else
============================================================
Index: libgfortran/generated/eoshift3_8.c
--- generated/eoshift3_8.c 4 May 2005 21:38:16 -0000 1.6
+++ generated/eoshift3_8.c 15 May 2005 12:38:45 -0000
@@ -1,5 +1,5 @@
/* Implementation of the EOSHIFT intrinsic
- Copyright 2002 Free Software Foundation, Inc.
+ Copyright 2002, 2005 Free Software Foundation, Inc.
Contributed by Paul Brook <paul@nowt.org>
This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -78,6 +78,12 @@ eoshift3_8 (gfc_array_char *ret, gfc_arr
GFC_INTEGER_8 sh;
GFC_INTEGER_8 delta;
+ /* The compiler cannot figure out that these are set, initialize
+ them to avoid warnings. */
+ len = 0;
+ soffset = 0;
+ roffset = 0;
+
if (pwhich)
which = *pwhich - 1;
else
============================================================
Index: libgfortran/m4/eoshift1.m4
--- m4/eoshift1.m4 4 May 2005 21:38:15 -0000 1.7
+++ m4/eoshift1.m4 15 May 2005 12:38:45 -0000
@@ -1,5 +1,5 @@
`/* Implementation of the EOSHIFT intrinsic
- Copyright 2002 Free Software Foundation, Inc.
+ Copyright 2002, 2005 Free Software Foundation, Inc.
Contributed by Paul Brook <paul@nowt.org>
This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -77,6 +77,12 @@ eoshift1_`'atype_kind (const gfc_array_c
atype_name sh;
atype_name delta;
+ /* The compiler cannot figure out that these are set, initialize
+ them to avoid warnings. */
+ len = 0;
+ soffset = 0;
+ roffset = 0;
+
if (pwhich)
which = *pwhich - 1;
else
============================================================
Index: libgfortran/m4/eoshift3.m4
--- m4/eoshift3.m4 4 May 2005 21:38:15 -0000 1.7
+++ m4/eoshift3.m4 15 May 2005 12:38:46 -0000
@@ -1,5 +1,5 @@
`/* Implementation of the EOSHIFT intrinsic
- Copyright 2002 Free Software Foundation, Inc.
+ Copyright 2002, 2005 Free Software Foundation, Inc.
Contributed by Paul Brook <paul@nowt.org>
This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -79,6 +79,12 @@ eoshift3_`'atype_kind (gfc_array_char *r
atype_name sh;
atype_name delta;
+ /* The compiler cannot figure out that these are set, initialize
+ them to avoid warnings. */
+ len = 0;
+ soffset = 0;
+ roffset = 0;
+
if (pwhich)
which = *pwhich - 1;
else
============================================================
Index: libgfortran/intrinsics/spread_generic.c
--- intrinsics/spread_generic.c 4 May 2005 21:38:15 -0000 1.8
+++ intrinsics/spread_generic.c 15 May 2005 12:38:46 -0000
@@ -1,5 +1,5 @@
/* Generic implementation of the SPREAD intrinsic
- Copyright 2002 Free Software Foundation, Inc.
+ Copyright 2002, 2005 Free Software Foundation, Inc.
Contributed by Paul Brook <paul@nowt.org>
This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -45,7 +45,7 @@ spread (gfc_array_char *ret, const gfc_a
/* r.* indicates the return array. */
index_type rstride[GFC_MAX_DIMENSIONS];
index_type rstride0;
- index_type rdelta;
+ index_type rdelta = 0;
index_type rrank;
index_type rs;
char *rptr;
============================================================
Index: libgfortran/intrinsics/eoshift0.c
--- intrinsics/eoshift0.c 4 May 2005 21:38:15 -0000 1.10
+++ intrinsics/eoshift0.c 15 May 2005 12:38:46 -0000
@@ -1,5 +1,5 @@
/* Generic implementation of the EOSHIFT intrinsic
- Copyright 2002 Free Software Foundation, Inc.
+ Copyright 2002, 2005 Free Software Foundation, Inc.
Contributed by Paul Brook <paul@nowt.org>
This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -64,6 +64,12 @@ eoshift0 (gfc_array_char * ret, const gf
index_type len;
index_type n;
+ /* The compiler cannot figure out that these are set, initialize
+ them to avoid warnings. */
+ len = 0;
+ soffset = 0;
+ roffset = 0;
+
if (!pbound)
pbound = zeros;
============================================================
Index: libgfortran/io/list_read.c
--- io/list_read.c 23 Apr 2005 12:38:08 -0000 1.18
+++ io/list_read.c 15 May 2005 12:38:46 -0000
@@ -2026,8 +2026,8 @@ nml_get_obj_data (void)
char c;
char * ext_name;
namelist_info * nl;
- namelist_info * first_nl;
- namelist_info * root_nl;
+ namelist_info * first_nl = NULL;
+ namelist_info * root_nl = NULL;
int dim;
int component_flag;
--
Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj
SUSE Linux Products GmbH, Maxfeldstr. 5, 90409 N?rnberg, Germany
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050515/07345783/attachment-0001.sig>
More information about the Fortran
mailing list