tmpnam() core dumping

Bill Ahlbrandt bahlbr@icdata.com
Fri Dec 12 06:18:00 GMT 1997


I am getting a core dump when I use the tmpnam() function.

I'm running slackware 2.0.29, 

gcc -v gives:

Reading specs from /usr/local/lib/gcc-lib/i486-pc-linux-gnulibc1/egcs-2.90.21/specs
gcc version egcs-2.90.21 971202 (egcs-1.00 release)

This probably has nothing to do with egcs, but being extremely new this environment and compiler, any assistance will be much appreciated.

Note that the tempnam function works just fine.


The following code produces the output that follows:

#include <stdio.h>

int main() {
  char *tempFileName;
  printf("doing tempnam\n");
  tempFileName=tempnam(".","xxx");
  printf("done\n");
  if (tempFileName) {
    printf("I got %s\n",tempFileName);
  } else {
    printf("Got an error\n");
  } /* endif */

  printf("doing tmpnam\n");
  tempFileName=tmpnam("xxx");
  printf("done\n");
  if (tempFileName) {
    printf("I got %s\n",tempFileName);
  } else {
    printf("Got an error\n");
  } /* endif */
  return 0;
}


mail:~/src/bug$ gcc bug.cpp
mail:~/src/bug$ a.out
doing tempnam
done
I got ./xxx30905aaa
doing tmpnam
Segmentation fault (core dumped)
mail:~/src/bug$                                                                                                                                       


Thanks in advance.

Bill Ahlbrandt





More information about the Gcc mailing list