This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: [Patch, Fortran] PR 47474: NULL init for scalar allocatable result vars with allocatable components


On 01/26/2011 08:35 AM, Tobias Burnus wrote:
Dear all,

functions such as

function func() result(res)
type(tx), allocatable :: res

produced code such as:

struct tx * res;
res.i.data = 0B; /*<<<< WRONG. */
res = 0B;

where the component is initialized although the pointer "res" is not associated.
If one simply swaps the "if (alloc_comp) {...} else if (dimension == 0 &&
allocatable) { ... } the result is OK but there are two

res = 0B;
res = 0B;

if there is a separate result variable and one if the function name matches the
result variable; thus, I added the extra "sym == sym->result" check.

Note that I failed for some reason to generate a failing test case. Thus, I did
not include one. (I found the bug when trying a patch for P4-regression PR 47455
- thus, that PR might contain a test case.)

Build and regtested on x86-64-linux.
OK for the trunk?

OK, and thanks for patch.


Jerry


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