This is the essence of one the errors that one of my programs is seeing. It is a Double Wammy - first the open of the direct access file fails for no reason - then it get an internal library error. g77 and Absoft are happy with it. [dir:~/tests/gfortran] dir% gfortran -g -o recursive recursive.f [dir:~/tests/gfortran] dir% recursive At line 14 of file recursive.f Internal Error: Recursive library calls not allowed [dir:~/tests/gfortran] dir% cat recursive.f program main CHARACTER*8 STATUS STATUS='SCRATCH' NT=55 NTAP29=29 NRECL=64 NPUINT=4 OPEN(UNIT=NT,STATUS=STATUS,ACCESS='DIRECT', $ FORM='UNFORMATTED',RECL=NRECL*NPUINT,ERR=999) STOP 999 CONTINUE OPEN (NTAP29, STATUS='SCRATCH') STOP END
Confirmed.
This is two bugs. The first bug can be reduced to $ cat open-opt.f open(unit=10,status="scratch ") end $ gfortran open-opt.f $ ./a.out At line 1 of file open-opt.f Fortran runtime error: Bad STATUS parameter in OPEN statement
This has a pretty good chance of fixing it. Proper testing, Changelog entry, ... tomorrow. Index: string.c =================================================================== RCS file: /cvsroot/gcc/gcc/libgfortran/runtime/string.c,v retrieving revision 1.4 diff -c -r1.4 string.c *** string.c 12 Jan 2005 21:27:31 -0000 1.4 --- string.c 23 Feb 2005 23:28:02 -0000 *************** *** 41,57 **** compare0 (const char *s1, int s1_len, const char *s2) { int i; ! if (strncasecmp (s1, s2, s1_len) != 0) ! return 0; ! ! /* The rest of s1 needs to be blanks for equality. */ ! ! for (i = strlen (s2); i < s1_len; i++) ! if (s1[i] != ' ') ! return 0; ! ! return 1; } --- 41,51 ---- compare0 (const char *s1, int s1_len, const char *s2) { int i; + int len; ! /* Strip traling blanks from the Fortran string. */ ! len = fstrlen(s1, s1_len); ! return strncasecmp(s1,s2,len) == 0; }
Patch for the first bug here: http://gcc.gnu.org/ml/gcc-patches/2005-02/msg01694.html
Here is a reduced test case for the second error: $ cat open-after-error.f open(10,status="foo",err=100) call abort 100 continue open(10,status="scratch") end $ cat open-after-error.f open(10,status="foo",err=100) call abort 100 continue open(10,status="scratch") end $ gfortran open-after-error.f $ ./a.out At line 4 of file open-after-error.f Internal Error: Recursive library calls not allowed
Looks like a missing call to library_end ()in open.c. I added that one line and the recursive error went away - [dir:~/tests/gfortran] dir% gfortran -o recursive3 recursive3.f [dir:~/tests/gfortran] dir% recursive3 [dir:~/tests/gfortran] dir% cat recursive3.f open(10,status="foo",err=100) call abort 100 continue open(10,status="scratch") end > [dir:~] dir% diff -c /Users/dir/junk/io/open.c /Users/dir/gfortran/gcc/libgfortran/io/open.c *** /Users/dir/junk/io/open.c Sat Jan 22 16:14:30 2005 --- /Users/dir/gfortran/gcc/libgfortran/io/open.c Sat Feb 26 21:36:28 2005 *************** *** 480,488 **** if (flags.position == POSITION_UNSPECIFIED) flags.position = POSITION_ASIS; ! if (ioparm.library_return != LIBRARY_OK) return; ! u = find_unit (ioparm.unit); if (u == NULL) --- 480,489 ---- if (flags.position == POSITION_UNSPECIFIED) flags.position = POSITION_ASIS; ! if (ioparm.library_return != LIBRARY_OK){ ! library_end (); return; ! } u = find_unit (ioparm.unit); if (u == NULL) (In reply to comment #5) > Here is a reduced test case for the second error: > > $ cat open-after-error.f > open(10,status="foo",err=100) > call abort > 100 continue > open(10,status="scratch") > end > $ cat open-after-error.f > open(10,status="foo",err=100) > call abort > 100 continue > open(10,status="scratch") > end > $ gfortran open-after-error.f > $ ./a.out > At line 4 of file open-after-error.f > Internal Error: Recursive library calls not allowed >
Subject: Bug 20163 CVSROOT: /cvs/gcc Module name: gcc Changes by: fxcoudert@gcc.gnu.org 2005-03-29 08:37:32 Modified files: gcc/testsuite : ChangeLog libgfortran : ChangeLog libgfortran/io : open.c Added files: gcc/testsuite/gfortran.dg: pr20163-2.f Log message: PR libfortran/20163 * io/open.c (st_open): call library_end() before returning even if an error arises. * gfortran.dg/pr20163-2.f: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5228&r2=1.5229 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/pr20163-2.f.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.178&r2=1.179 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/open.c.diff?cvsroot=gcc&r1=1.11&r2=1.12
Subject: Bug 20163 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: fxcoudert@gcc.gnu.org 2005-03-29 08:41:58 Modified files: gcc/testsuite : ChangeLog libgfortran : ChangeLog libgfortran/io : open.c Added files: gcc/testsuite/gfortran.dg: pr20163-2.f Log message: PR libfortran/20163 * io/open.c (st_open): call library_end() before returning even if an error arises. * gfortran.dg/pr20163-2.f: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.71&r2=1.5084.2.72 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/pr20163-2.f.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.163.2.11&r2=1.163.2.12 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/open.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.10.10.1&r2=1.10.10.2
Fixed.
Subject: Bug 20163 CVSROOT: /cvs/gcc Module name: gcc Changes by: tkoenig@gcc.gnu.org 2005-04-09 19:37:14 Modified files: libgfortran : ChangeLog libgfortran/runtime: string.c Log message: 2005-04-09 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/20163 * runtime/string.c (compare0): Use fstrlen() to strip trailing blanks from option string. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.185&r2=1.186 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/runtime/string.c.diff?cvsroot=gcc&r1=1.4&r2=1.5
Subject: Bug 20163 CVSROOT: /cvs/gcc Module name: gcc Changes by: tkoenig@gcc.gnu.org 2005-04-09 19:40:48 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/gfortran.dg: open-options-blanks.f Log message: 2005-04-09 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/20163 * gfortran.dg/open-options-blanks.f: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5313&r2=1.5314 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/open-options-blanks.f.diff?cvsroot=gcc&r1=NONE&r2=1.1
First half is ixed in 4.1.0 - waiting for 4.0 to reopen.
*** Bug 20749 has been marked as a duplicate of this bug. ***
Subject: Bug 20163 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: tkoenig@gcc.gnu.org 2005-04-13 20:48:16 Modified files: libgfortran : ChangeLog libgfortran/runtime: string.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gfortran.dg: open-options-blanks.f Log message: Committed after approval on http://gcc.gnu.org/ml/gcc/2005-04/msg00613.html. 2005-04-13 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/20163 * runtime/string.c (compare0): Use fstrlen() to strip trailing blanks from option string. 2005-04-13 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/20163 * gfortran.dg/open-options-blanks.f: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.163.2.17&r2=1.163.2.18 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/runtime/string.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4&r2=1.4.12.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.122&r2=1.5084.2.123 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/open-options-blanks.f.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
Fixed on 4.0 too.