[patch, fortran] Don't initialize components of pointers to derived compounds (PR30793)
Tobias Burnus
burnus@net-b.de
Thu Feb 15 17:23:00 GMT 2007
:ADDPATCH fortran:
If a function returns a variable of a derived type, its components are
initialized. (So far so good.) Unfortunally, gfortran also initializes
the components if the variable is only a pointer to a derived compound.
This yields to code like the following:
get_scalar_field_msh (fld)
{
struct mesh * __result_get_scalar_field_msh;
__result_get_scalar_field_msh->area.data = 0B; /* SIC! */
__result_get_scalar_field_msh->dist.data = 0B; /* SIC! */
__result_get_scalar_field_msh->interp.data = 0B; /* SIC! */
__result_get_scalar_field_msh = msh_ (&fld->base);
return __result_get_scalar_field_msh;
}
Solution: Well, simply don't initialize the components, if we have a
function which returns a pointer.
The following patch has been build and regression tested on
x86_64-unknown-linux-gnu.
Thanks for Salvatore Filippone for sending in the test case.
Ok for the trunk and after a week or so for 4.2 and 4.1?
Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: func-ptr-derived.diff
Type: text/x-patch
Size: 3678 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070215/63c028e7/attachment.bin>
More information about the Fortran
mailing list