http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47439

           Summary: Fun with scratch files on Windows  MKTEMP only allows
                    for 26 files
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: bur...@gcc.gnu.org
                CC: jvdeli...@gcc.gnu.org, j...@gcc.gnu.org


Reported by Claude Simone at
http://groups.google.com/group/comp.lang.fortran/msg/b1bf5ce50080e89e

Thread:
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/8843f2317cb565cd


A) Not more than 26 temporary files are possible

To generate a temporay file, libgfortran/io/unix.c's tempfile calls the
system's mktemp, which according to Microsoft's API has the following property:

http://msdn.microsoft.com/en-us/library/34wc6k1f%28v=VS.80%29.aspx

"_mktemp preserves base and replaces the first trailing X with an alphabetic
character. _mktemp replaces the following trailing X's with a five-digit value;
this value is a unique number identifying the calling process, or in
multithreaded programs, the calling thread."

Hence, there are only "a" to "z" = 26 temporary files possible - at least
concurrently. Thus, for Windows systems, gfortran needs an own implementation
for mk(s)temp, which supports more. One possibility would be to change the BASE
handed to "mktemp".



B) Files are not unlinked

Newer Windows support for FILE_FLAG_DELETE_ON_CLOSE; cf. CreateFile Function at
http://msdn.microsoft.com/en-us/library/aa363858%28VS.85%29.aspx

See also http://msdn.microsoft.com/en-us/library/yeby3zcb%28v=VS.80%29.aspx for
"D" and "_O_TEMPORARY" in fopen and _wfopen.


However, in principle on exit libgfortran's
  static void __attribute__((destructor))
  cleanup (void)
should be called, which should delete files.

Reply via email to