This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
RFC: DTIO and PR82007
- From: Jerry DeLisle <jvdelisle at charter dot net>
- To: gfortran <fortran at gcc dot gnu dot org>
- Date: Fri, 5 Jan 2018 10:57:11 -0800
- Subject: RFC: DTIO and PR82007
- Authentication-results: sourceware.org; auth=none
Hi all,
I have spent some time looking at the Fortran standard and our implementation in
trans-io.c.
PR82007 is caused by an attempt to determine when to compile in the calls for
DTIO based on the content of the format string. If the format string is a
variable or function expression, the test for 'DT' will not work and actually
leads to a segfault. I posted a preliminary patch in the PR that removes all
that code and just assumes that if the user has provided a user defined
procedure to just use it.
However, the standard is pretty clear that if a derived type item is encountered
in the IO list and there is no corresponding DT format specifier, then the
derived type is treated as a list of its components as effective items, the IO
proceeds without using the user defined procedure even if it is present.
There are two approaches we can take that I can see at the moment.
1) Compile a list of the components int the dtp structure similar to what we do
for namelists so that if a DT edit descriptor is not found at run time, the
library can simple traverse the derived time data.
or
2) Modify the front end to build conditional execution path as follows:
Currently when a DTIO is present we do this:
st_write
transfer_derived
st_write_done
Instead do this:
st_write
{
if (DT present)
transfer_derived
else
transfer_component_a
transfer_component_b
.
.
.
endif
}
st_write_done
The library side would have to set DT_present at run time so that execution will
be dependent on what is provided by the program running.
If the format string at compile time is a constant expression, even if we parsed
it, we would not easily know it corresponds in line with the IO list, it could
be done of course. One would have to walk the I/O list and walk the format
string and check. We should probably do that anyway just to provide better
compile time format checking.
I cant get all the above done right away. I would like to submit the
preliminary patch which covers 90 percent and avoids the failures of pr82007 and
address the rest later.
Any thoughts from anyone else on the above?
Regards,
Jerry