Bug 19194 - Missing RECL parameter in OPEN statement
Summary: Missing RECL parameter in OPEN statement
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: patch, wrong-code
: 16288 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-12-29 21:38 UTC by John David Anglin
Modified: 2005-04-20 02:02 UTC (History)
3 users (show)

See Also:
Host: hppa64-hp-hpux11.11
Target: hppa64-hp-hpux11.11
Build: hppa64-hp-hpux11.11
Known to work:
Known to fail:
Last reconfirmed: 2004-12-30 01:24:42


Attachments
.t02.original dump (803 bytes, text/plain)
2005-01-05 00:17 UTC, John David Anglin
Details
Proposed patch (857 bytes, patch)
2005-01-05 00:49 UTC, Tobias Schlüter
Details | Diff
with patch (803 bytes, text/plain)
2005-01-05 02:32 UTC, John David Anglin
Details
.s file (1.18 KB, text/plain)
2005-01-05 04:25 UTC, John David Anglin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2004-12-29 21:38:17 UTC
Executing on host: /test/gnu/gcc-3.3/objdir/gcc/testsuite/../gfortran -B/test/gn
u/gcc-3.3/objdir/gcc/testsuite/../ /test/gnu/gcc-3.3/gcc/gcc/testsuite/gfortran.
dg/direct_io_2.f90   -O0   -pedantic-errors  -L/test/gnu/gcc-3.3/objdir/hppa64-h
p-hpux11.11/./libgfortran/.libs -L/test/gnu/gcc-3.3/objdir/hppa64-hp-hpux11.11/.
/libiberty  -lm   -o ./direct_io_2.exe    (timeout = 300)
PASS: gfortran.dg/direct_io_2.f90  -O0  (test for excess errors)
Setting LD_LIBRARY_PATH to .:/test/gnu/gcc-3.3/objdir/hppa64-hp-hpux11.11/./libg
fortran/.libs:/test/gnu/gcc-3.3/objdir/gcc:.:/test/gnu/gcc-3.3/objdir/hppa64-hp-
hpux11.11/./libgfortran/.libs:/test/gnu/gcc-3.3/objdir/gcc:/opt/gnu64/gcc/gcc-3.
5.0/lib
At line 9 of file /test/gnu/gcc-3.3/gcc/gcc/testsuite/gfortran.dg/direct_io_2.f9
0
Fortran runtime error: Missing RECL parameter in OPEN statement
FAIL: gfortran.dg/direct_io_2.f90  -O0  execution test

As the RECL parameter is there, it seems that the parsing of statements
must be broken on this 64-bit target.
Comment 1 Bud Davis 2004-12-30 01:24:42 UTC
this is a run time library bug.
Comment 2 Tobias Schlüter 2005-01-05 00:02:28 UTC
Can you attach the .t02.original dump (generated with -fdump-tree-original)
please. I have an idea what might be going wrong, but I'd like to see what this
looks like on your target.
Comment 3 John David Anglin 2005-01-05 00:17:06 UTC
Created attachment 7871 [details]
.t02.original dump
Comment 4 Tobias Schlüter 2005-01-05 00:49:01 UTC
Created attachment 7872 [details]
Proposed patch

Can you please give this a spin? The library used int where the compiler used
INTEGER*4 in a few cases. I'm currently running the testsuite on i686 and it
looks good so far, but I obviously can't test if it fixes the size mismatch.
Comment 5 dave 2005-01-05 02:01:51 UTC
Subject: Re:  Missing RECL parameter in OPEN statement

> Can you please give this a spin? The library used int where the compiler
> used
> INTEGER*4 in a few cases. I'm currently running the testsuite on i686 and it
> looks good so far, but I obviously can't test if it fixes the size mismatch.

Hmmm, it's actually long that changes between the 32 and 64-bit ports.

Dave
Comment 6 John David Anglin 2005-01-05 02:32:43 UTC
Created attachment 7873 [details]
with patch

There is a minor typo in the CHARACTER macro in the patch.  The space
after ` CHARACTER' need to be removed.	However, the error still occurs.
Comment 7 John David Anglin 2005-01-05 03:40:40 UTC
Looks as if the problem relates to the initialization or lack of the
_gfortran_ioparm struct:

(gdb) p (st_parameter)_gfortran_ioparm
$14 = {unit = 0, err = 0, end = 0, eor = 0, list_format = 0,
  library_return = LIBRARY_OK, iostat = 0x0, exist = 0x0, opened = 0x0,
  number = 0x0, named = 0x0, rec = 0, nextrec = 0x0, size = 0x0, recl_in = 0,
  recl_out = 0x0, iolength = 0x0, file = 0x0, file_len = 0, status = 0x0,
  status_len = 0, access = 0x0, access_len = 0, form = 0x0, form_len = 0,
  blank = 0x0, blank_len = 0, position = 0x0, position_len = 0, action = 0x0,
  action_len = 0, delim = 0x0, delim_len = 0, pad = 0x0, pad_len = 0,
  format = 0x0, format_len = 0, advance = 0x0, advance_len = 0, name = 0x0,
  name_len = 0, internal_unit = 0x0, internal_unit_len = 0, sequential = 0x0,
  sequential_len = 0, direct = 0x0, direct_len = 0, formatted = 0x0,
  formatted_len = 0, unformatted = 0x0, unformatted_len = 0, read = 0x0,
  read_len = 0, write = 0x0, write_len = 0, readwrite = 0x0,
  readwrite_len = 0, namelist_name = 0x0, namelist_name_len = 0,
  namelist_read_mode = 0}
Comment 8 John David Anglin 2005-01-05 04:22:46 UTC
Ignore the last comment.  Gdb is confused.

The fundamental problem is the following.  Here is the code generated
to save the recl_in field in MAIN__.  A store double word insn is being
used to store the recl_in field.  This is wrong as the field in an int.

        ldi 80,%r28
        std %r28,88(%r31)

The field is accessed as an int in io/open.c.  Because this is a big
endian target, it reads back a 0.  80 is in the following word (int).
Comment 9 John David Anglin 2005-01-05 04:25:10 UTC
Created attachment 7874 [details]
.s file
Comment 10 Tobias Schlüter 2005-01-05 17:12:48 UTC
I don't understand why my build hadn't picked up the changes to io.h, which made
me miss the typo.  Apart from that there's another inconsistency, cured by this
patch to trans-io.c.  Can you test this please?

2005-01-05  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>

        PR fortran/19194
        * trans-io.c (gfc_build_io_library_fndecls): 'recl_in' is not a pointer
        field.

Index: trans-io.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans-io.c,v
retrieving revision 1.25
diff -u -p -r1.25 trans-io.c
--- trans-io.c  3 Jan 2005 21:43:55 -0000       1.25
+++ trans-io.c  5 Jan 2005 17:07:59 -0000
@@ -185,7 +185,7 @@ gfc_build_io_library_fndecls (void)
   ADD_FIELD (nextrec, gfc_pint4_type_node);
   ADD_FIELD (size, gfc_pint4_type_node);

-  ADD_FIELD (recl_in, gfc_pint4_type_node);
+  ADD_FIELD (recl_in, gfc_int4_type_node);
   ADD_FIELD (recl_out, gfc_pint4_type_node);

   ADD_FIELD (iolength, gfc_pint4_type_node);
Comment 11 Tobias Schlüter 2005-01-05 17:44:49 UTC
BTw the build issue is now PR 19273.
Comment 12 Tobias Schlüter 2005-01-05 19:39:10 UTC
*** Bug 16288 has been marked as a duplicate of this bug. ***
Comment 13 dave 2005-01-05 22:19:13 UTC
Subject: Re:  Missing RECL parameter in OPEN statement

>   Can you test this please?
> 
> 2005-01-05  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
> 
>         PR fortran/19194
>         * trans-io.c (gfc_build_io_library_fndecls): 'recl_in' is not a
> pointer
>         field.

I'm now seeing the following error:

Executing on host: /test/gnu/gcc-3.3/objdir/gcc/testsuite/../gfortran -B/test/gn
u/gcc-3.3/objdir/gcc/testsuite/../ /test/gnu/gcc-3.3/gcc/gcc/testsuite/gfortran.
dg/direct_io_2.f90   -O0   -pedantic-errors  -L/test/gnu/gcc-3.3/objdir/hppa64-h
p-hpux11.11/./libgfortran/.libs -L/test/gnu/gcc-3.3/objdir/hppa64-hp-hpux11.11/.
/libiberty  -lm   -o ./direct_io_2.exe    (timeout = 300)
PASS: gfortran.dg/direct_io_2.f90  -O0  (test for excess errors)
Setting LD_LIBRARY_PATH to .:/test/gnu/gcc-3.3/objdir/hppa64-hp-hpux11.11/./libg
fortran/.libs:/test/gnu/gcc-3.3/objdir/gcc:.:/test/gnu/gcc-3.3/objdir/hppa64-hp-
hpux11.11/./libgfortran/.libs:/test/gnu/gcc-3.3/objdir/gcc
At line 15 of file /test/gnu/gcc-3.3/gcc/gcc/testsuite/gfortran.dg/direct_io_2.f
90
Fortran runtime error: Direct access data transfer requires record number
FAIL: gfortran.dg/direct_io_2.f90  -O0  execution test

Dave
Comment 14 Tobias Schlüter 2005-01-06 00:16:55 UTC
Sigh, indeed the type for the REC parameter is wrong as well.  I had checked for
other wrongs, but due to unlucky formatting in io.h I missed this one.

Could you please try this patch to trans-io.c instead of the previous one?

2005-01-05  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>

        PR fortran/19194
        * trans-io.c (gfc_build_io_library_fndecls): 'rec' and 'recl_in' are
        not pointer fields.

Index: trans-io.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans-io.c,v
retrieving revision 1.25
diff -u -p -r1.25 trans-io.c
--- trans-io.c  3 Jan 2005 21:43:55 -0000       1.25
+++ trans-io.c  6 Jan 2005 00:14:10 -0000
@@ -181,11 +181,11 @@ gfc_build_io_library_fndecls (void)
   ADD_FIELD (opened, gfc_pint4_type_node);
   ADD_FIELD (number, gfc_pint4_type_node);
   ADD_FIELD (named, gfc_pint4_type_node);
-  ADD_FIELD (rec, gfc_pint4_type_node);
+  ADD_FIELD (rec, gfc_int4_type_node);
   ADD_FIELD (nextrec, gfc_pint4_type_node);
   ADD_FIELD (size, gfc_pint4_type_node);

-  ADD_FIELD (recl_in, gfc_pint4_type_node);
+  ADD_FIELD (recl_in, gfc_int4_type_node);
   ADD_FIELD (recl_out, gfc_pint4_type_node);

   ADD_FIELD (iolength, gfc_pint4_type_node);
Comment 15 Tobias Schlüter 2005-01-06 00:35:52 UTC
David (billingd) could you please test this last patch on MIPS if John David's
(danglin) testing turns out to be successful? I could then submit it (+ cleanups
to io.h) tomorrow.
Comment 16 dave 2005-01-06 04:36:09 UTC
Subject: Re:  Missing RECL parameter in OPEN statement

> Could you please try this patch to trans-io.c instead of the previous one?
> 
> 2005-01-05  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
> 
>         PR fortran/19194
>         * trans-io.c (gfc_build_io_library_fndecls): 'rec' and 'recl_in' are
>         not pointer fields.

This fixes all the errors of this type in the testsuite.  Will try
to file PRs on the remaining problems when I get a chance.

Thanks,
Dave
Comment 17 Tobias Schlüter 2005-01-06 13:35:18 UTC
Patch here: http://gcc.gnu.org/ml/fortran/2005-01/msg00043.html
Comment 18 GCC Commits 2005-01-22 14:37:49 UTC
Subject: Bug 19194

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tobi@gcc.gnu.org	2005-01-22 14:37:39

Modified files:
	libgfortran    : ChangeLog 
	libgfortran/io : io.h 
	gcc/fortran    : ChangeLog trans-io.c 

Log message:
	gcc/fortran/
	PR fortran/19194
	* trans-io.c (ADD_STRING): Use gfc_charlen_type_node for string
	length parameters.
	(gfc_build_io_library_fndecls): 'rec' and 'recl_in' are not
	pointer fields.
	
	libgfortran/
	PR fortran/19194
	* io/io.h (st_parameter): Use 'GFC_INTEGER_4' instead of 'int',
	use CHARACTER macro for definition of string valued paramters.
	
	Also fix years in recent ChangeLog entries.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.148&r2=1.149
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/io.h.diff?cvsroot=gcc&r1=1.14&r2=1.15
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.304&r2=1.305
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-io.c.diff?cvsroot=gcc&r1=1.26&r2=1.27

Comment 19 Tobias Schlüter 2005-01-22 14:40:29 UTC
Fixed.