delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/01/19:18:50

From: wogl AT pizpalue DOT mchp DOT siemens DOT de (Wolfgang Glunz)
Newsgroups: comp.os.msdos.djgpp
Subject: bug in tempnam ?
Date: 1 Oct 1997 17:07:56 GMT
Organization: Siemens Inc.
Lines: 29
Distribution: world
Message-ID: <60u01c$dl9$1@salomon.mchp.siemens.de>
Reply-To: Wolfgang DOT Glunz AT mchp DOT siemens DOT de
NNTP-Posting-Host: pizpalue.mchp.siemens.de
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

A user of pstoedit (ftp://sunsite.cnlab-switch.ch/mirror/X11/contrib/applications/pstoedit/pstoedit.html)
tried to make pstoedit under gjgpp. Unfortunately the program did not run as expected.
Together we found out that there might be a bug in the c-library function tempnam (not tmpnam !).
Under all other systems I known, tempnam returns a pointer to newly allocated memory if
the first parameter is 0. Under djgpp 2.01 it looks like that tempnam behaves the
same as tmpnam which returns a pointer to a static memory which is overwritten after
each call to tmpnam.

The following program illustrates the possible bug;

#include <iostream.h>
#include <stdio.h>
 
int main()
{
 char * p1 = tempnam(0,"t1");
 char * p2 = tempnam(0,"t2");
 cout << p1 << " " << p2 << endl;
};
 

Normally one gets two different values whereas under
djgpp 2.01 p1 and p2 are the same.

	Wolfgang

-- 
Wolfgang Glunz            email: Wolfgang DOT Glunz AT mchp DOT siemens DOT de

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019