This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libfortran/24787] New: [libfortran] SCAN is broken
- From: "kargl at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Nov 2005 07:40:44 -0000
- Subject: [Bug libfortran/24787] New: [libfortran] SCAN is broken
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider
program b
integer w
character(len=2) s
s = 'xi'
w = scan(s, 'iI')
print *, s, w
end program b
When compiled and executed, this should produce "xi 2".
Here is NAG's F95 results.
kargl[280] f95 -o z scan1.f90
kargl[281] ./z
xi 2
Here's the incorrect gfortran results.
kargl[282] gfc41 -static -o z -O -fdump-tree-original scan1.f90
kargl[283] ./z
xi 0
Here's the tree
MAIN__ ()
{
char s[1:2];
int4 w;
_gfortran_copy_string (2, &s, 2, "xi");
w = _gfortran_string_scan (2, &s, 2, "iI", 0);
_gfortran_filename = "scan1.f90";
_gfortran_line = 6;
_gfortran_ioparm.unit = 6;
_gfortran_ioparm.list_format = 1;
_gfortran_st_write ();
_gfortran_transfer_character (&s, 2);
_gfortran_transfer_integer (&w, 4);
_gfortran_st_write_done ();
}
It looks like either "char s[1:2]" should be "char s[0:1]"
or _gfortran_string_scan (2, &s, 2, "iI", 0) may be indexing
incorrectly.
Yep! Changing "character(len=2) s" to character(len=3) s"
gives "xi 2" for the results.
--
Summary: [libfortran] SCAN is broken
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libfortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kargl at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24787