This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libfortran/51803] New: gfortran getcwd at startup
- From: "mrs at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 09 Jan 2012 20:56:42 +0000
- Subject: [Bug libfortran/51803] New: gfortran getcwd at startup
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51803
Bug #: 51803
Summary: gfortran getcwd at startup
Classification: Unclassified
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libfortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: mrs@gcc.gnu.org
This code:
memset (buf, 0, sizeof (buf));
#ifdef HAVE_GETCWD
cwd = getcwd (buf, sizeof (buf));
#else
cwd = "";
#endif
/* exe_path will be cwd + "/" + argv[0] + "\0" */
path = malloc (strlen (cwd) + 1 + strlen (argv0) + 1);
sprintf (path, "%s%c%s", cwd, DIR_SEPARATOR, argv0);
exe_path = path;
please_free_exe_path_when_done = 1;
from libgfortran/runtime/main.c:store_exe_path is bad. getcwd can fail with a
0 return status. I didn't have getdents wired up completely in my simulator,
and fortran fails everything in the testsuite because of it. :-(
Should be something like:
#ifdef HAVE_GETCWD
cwd = getcwd (buf, sizeof (buf));
if (cwd == 0)
cwd = "";
#else