This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: tmpnam() core dumping
- To: egcs at cygnus dot com
- Subject: Re: tmpnam() core dumping
- From: Tim Hollebeek <tim at wagner dot Princeton dot EDU>
- Date: Fri, 12 Dec 1997 18:35:26 -0500 (EST)
- Reply-To: egcs at cygnus dot com
Bill Ahlbrandt writes ...
>
> Yes, using -fwritable-strings fixes the problem.
>
> I wonder why these functions want to modify the string that is passed to them :-)?
Normal behavior. Otherwise they would have to call malloc() to allocate the
result, or something similar. E.g. from the IRIX man page:
tmpnam always generates a file name using the path-prefix defined as
P_tmpdir in the <stdio.h> header file. If s is NULL, tmpnam leaves its
result in an internal static area and returns a pointer to that area.
The next call to tmpnam will destroy the contents of the area. If s is
not NULL, it is assumed to be the address of an array of at least
L_tmpnam bytes, where L_tmpnam is a constant defined in <stdio.h>; tmpnam
places its result in that array and returns s.
---------------------------------------------------------------------------
Tim Hollebeek | "Everything above is a true
email: tim@wfn-shop.princeton.edu | statement, for sufficiently
URL: http://wfn-shop.princeton.edu/~tim | false values of true."