This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[FORTRAN PATCH] Fix type punning problem in mio_array_ref


I'm working on a better fix to the current fortran/symbol.c array bounds
warning bootstrap failure on mainline.  In the process, that fix exposes
a latent "type punning breaks strict aliasing" warning from gfortran's
module.c.  It turns out that mio_array_ref is making non-portable
assumptions and this is potentially a real (latent?) bug.

Line 1917 casts the address of the dimen_type field to a pointer type. 
Unfortunately, dimen_type is an anonymous enumerated type, which isn't
guaranteed to have the same size as an integer.  Hence the warning/bug.
The fix below is to loop over each element of the array and cast the
fields between the enumerated type (which might be a char or a short) and
and integer, and pass its address to the low-level module I/O routines.

The following patch has been tested on x86_64-unknown-linux-gnu, with a
full "make bootstrap" and tested with a top-level "make -k check" with no
new failures [though there were other bootstrap fixing changes in the
tree].  Hopefully, the content/intent of this change should be obvious.

Ok for mainline?


2007-01-20  Roger Sayle  <roger@eyesopen.com>

        * module.c (mio_array_ref): The dimen_type fields of an array ref
        are an enumerated type and can't be read/written directly with a
        call to mio_integer.  Instead loop over and cast each element.

Roger
--

Attachment: patchf.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]