This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libf2c/11918] New: isatty does not call f_init
- From: "nvwarr at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Aug 2003 12:20:11 -0000
- Subject: [Bug libf2c/11918] New: isatty does not call f_init
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11918
Summary: isatty does not call f_init
Product: gcc
Version: 3.2.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libf2c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: nvwarr at hotmail dot com
CC: gcc-bugs at gcc dot gnu dot org
When calling a fortran subroutine from a C program, using isatty on stdin gives
a segmentation fault:
#0 0x400db449 in fileno_unlocked () from /lib/i686/libc.so.6
#1 0x40040417 in G77_fnum_0 () from /usr/lib/libg2c.so.0
#2 0x400407c8 in G77_isatty_0 () from /usr/lib/libg2c.so.0
This does not occur if f_init is called either explicitly from the C program, or
implicitly by calling some function which calls f_init.
There are three ways to fix it:
1) modify the C program to call f_init explicitly.
2) add a dummy write statement to the fortran code to force it to call f_init
implicitly
3) add a line to libf2c/libU77/isatty_.c:
if (f__init != 1) f_init();
Perhaps this line should really be added to libf2c/libU77/fnum_.c?
Probably there is another bug involving fnum as well. It looks as though the
code doesn't check if
the unit is actually open, so calling isatty (and anything else which calls
fnum) with a unit which has
been closed (or never opened) will cause a segmentation fault in fileno_unlocked
rather than a useful error message, regardless of whether f_init has been called
or not.