Bug 19314 - inquire(position=) segfaults at runtime
Summary: inquire(position=) segfaults at runtime
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2005-01-07 15:43 UTC by Thomas Koenig
Modified: 2005-01-22 06:59 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-01-17 04:41:10


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2005-01-07 15:43:20 UTC
Because of the segfault, I assume that this is different from PR 19313.

$ cat inquire-position.f
      character*20 chr
      open(7)
      inquire(7,position=chr)
      print *,chr
      end
$ gfortran inquire-position.f
$ ./a.out
Segmentation fault
$ gfortran -v ; gfortran -dumpmachine
Using built-in specs.
Configured with: ../gcc-4.0-20050102/configure --prefix=/home/zfkts
--enable-languages=c,c++,f95
Thread model: posix
gcc version 4.0.0 20050102 (experimental)
ia64-unknown-linux-gnu

$ gfortran -g inquire-position.f
$ gdb ./a.out
GNU gdb Red Hat Linux (6.1post-1.20040607.52rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "ia64-redhat-linux-gnu"...Using host libthread_db
library "/lib/tls/libthread_db.so.1".

(gdb) r
Starting program: /home/zfkts/Krempel/a.out

Program received signal SIGSEGV, Segmentation fault.
0x20000000002cee11 in strlen () from /lib/tls/libc.so.6.1
(gdb) bt
#0  0x20000000002cee11 in strlen () from /lib/tls/libc.so.6.1
#1  0x2000000000052470 in *_gfortrani_cf_strcpy (dest=0x0, dest_len=0, src=0x0)
    at ../../../gcc-4.0-20050102/libgfortran/runtime/string.c:84
#2  0x20000000000a3890 in inquire_via_unit (u=0x600000000000a2e0)
    at ../../../gcc-4.0-20050102/libgfortran/io/inquire.c:166
#3  0x20000000000a48a0 in *_gfortran_st_inquire ()
    at ../../../gcc-4.0-20050102/libgfortran/io/inquire.c:370
#4  0x4000000000000cb0 in MAIN__ () at inquire-position.f:3
#5  0x4000000000000df0 in main (argc=1, argv=0x60000fffffffa108)
    at ../../../gcc-4.0-20050102/libgfortran/fmain.c:18
(gdb)
Comment 2 GCC Commits 2005-01-22 03:51:24 UTC
Subject: Bug 19314

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	bdavis@gcc.gnu.org	2005-01-22 03:51:13

Modified files:
	gcc/testsuite  : ChangeLog 
	libgfortran    : ChangeLog 
	libgfortran/io : inquire.c rewind.c transfer.c 
Added files:
	gcc/testsuite/gfortran.dg: inquire_5.f90 

Log message:
	2004-01-22  Bud Davis  <bdavis9659@comcast.net>
	
	PR fortran/19314
	* io/inquire.c(inquire_via_unit): implement POSITION=.
	* io/transfer.c(next_record): update position for
	INQUIRE.
	* io/rewind.c(st_rewind): update position for
	INQUIRE.
	
	* gfortran.dg/inquire_5.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4920&r2=1.4921
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/inquire_5.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.147&r2=1.148
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/inquire.c.diff?cvsroot=gcc&r1=1.7&r2=1.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/rewind.c.diff?cvsroot=gcc&r1=1.8&r2=1.9
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/transfer.c.diff?cvsroot=gcc&r1=1.27&r2=1.28

Comment 3 Andrew Pinski 2005-01-22 06:59:49 UTC
Fixed.