[Bug libfortran/69651] [6 Regession] Usage of unitialized pointer io/list_read.c
jvdelisle at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Feb 13 20:12:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69651
--- Comment #9 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
(In reply to Jerry DeLisle from comment #8)
> This is a regression:
>
> With gfortran 5.3.1:
>
> $ ./a.out
> res, (1) == 1 !
>
> With gfortran 6.0.0 20160207 (experimental)
>
> $ ./a.out
> res, (1) == 80 �@�@�C
I have isolated the problem. When I defined '!' as a "separator" back in April
of 2015 (not 2016 mentioned in comment 5, I did not disable the feature when
reading strings with read_character in list_read.c.
We treat '!' as a separator for namelist reads to stop the read and then eat
the rest of the line as a comment. When trying to read the string containing a
'!' in the test case of this PR, we were just ending the read right away
resulting in not setting the variable SSS(1) to anything, read_character was
not even being called, so the string was left undefined with whatever happens
to be in memory.
I have a provisional patch that tests OK but begs a question:
Given:
program test
implicit none
integer :: i, j , k
i = -5
j = -6
open(10, file='testfile')
read(10,*) i, j
print *, i, j
close(10)
end program
and testfile:
10!12
****EOF****
What should the result be with non-namelist read?
I have it giving:
$gfc test.f90
$ ./a.out
10 -6
In other words, the embedded '!' is terminating the read with no error.
Replacing the '!' with a ',' or ' ' results in uninterrupted read printing 10
and 12.
More information about the Gcc-bugs
mailing list