These incorrect messages have been appearing lately. The variables are always and only accessed in the save branch of the switch statements - so they will never and can never be used uninitialized. [dranta:~/tests/gfortran-D] dir% gfortran -c -O2 -Wuninitialized module_files.f90 module_files.f90: In function 'my_sio_file_read_common': module_files.f90:36: warning: 'scratch_r8.dim[1].stride' may be used uninitialized in this function module_files.f90:36: warning: 'scratch_r8.offset' may be used uninitialized in this function module_files.f90:35: warning: 'scratch_i4.dim[1].stride' may be used uninitialized in this function module_files.f90:35: warning: 'scratch_i4.offset' may be used uninitialized in this function [dranta:~/tests/gfortran-D] dir% gfortran --v Using built-in specs. Target: powerpc-apple-darwin8.10.0 Configured with: ../gcc/configure --disable-bootstrap --enable-multilib --prefix=/usr/local/gfortran --enable-languages=c,fortran Thread model: posix gcc version 4.3.0 20070921 (experimental) (GCC)
Created attachment 14240 [details] The fortran source
*** Bug 33523 has been marked as a duplicate of this bug. ***
Patch below fixes it: Index: trans-types.c =================================================================== --- trans-types.c (revision 128661) +++ trans-types.c (working copy) @@ -1088,16 +1088,19 @@ gfc_get_desc_dim_type (void) decl = build_decl (FIELD_DECL, get_identifier ("stride"), gfc_array_index_type); DECL_CONTEXT (decl) = type; + TREE_NO_WARNING (decl) = 1; fieldlist = decl; decl = build_decl (FIELD_DECL, get_identifier ("lbound"), gfc_array_index_type); DECL_CONTEXT (decl) = type; + TREE_NO_WARNING (decl) = 1; fieldlist = chainon (fieldlist, decl); decl = build_decl (FIELD_DECL, get_identifier ("ubound"), gfc_array_index_type); DECL_CONTEXT (decl) = type; + TREE_NO_WARNING (decl) = 1; fieldlist = chainon (fieldlist, decl); /* Finish off the type. */ @@ -1389,12 +1392,14 @@ gfc_get_array_descriptor_base (int dimen decl = build_decl (FIELD_DECL, get_identifier ("offset"), gfc_array_index_type); DECL_CONTEXT (decl) = fat_type; + TREE_NO_WARNING (decl) = 1; fieldlist = chainon (fieldlist, decl); /* Add the dtype component. */ decl = build_decl (FIELD_DECL, get_identifier ("dtype"), gfc_array_index_type); DECL_CONTEXT (decl) = fat_type; + TREE_NO_WARNING (decl) = 1; fieldlist = chainon (fieldlist, decl); /* Build the array type for the stride and bound components. */ @@ -1406,6 +1411,7 @@ gfc_get_array_descriptor_base (int dimen decl = build_decl (FIELD_DECL, get_identifier ("dim"), arraytype); DECL_CONTEXT (decl) = fat_type; + TREE_NO_WARNING (decl) = 1; fieldlist = chainon (fieldlist, decl); /* Finish off the type. */
Subject: Bug 33522 Author: fxcoudert Date: Sat Sep 22 16:54:56 2007 New Revision: 128673 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128673 Log: PR fortran/33522 * trans-types.c (gfc_get_desc_dim_type): Mark artificial variables with TREE_NO_WARNING. (gfc_get_array_descriptor_base): Likewise. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-types.c
Fixed.