This is the mail archive of the 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]

[Bug libfortran/24787] New: [libfortran] SCAN is broken


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

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

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