[C++ PATCH] pr15551.C fix

David Edelsohn dje@watson.ibm.com
Sun Apr 23 16:26:00 GMT 2006


	When I run the G++ testsuite, g++.dg/opt/pr15551.C fails because
"unlink is not in scope".  The testcase does not appear to be including
any header file that will place unlink in the global or std namespaces.

	I do not see any precedent for deleting a file within a G++
testcase.  Most C++ references suggest using cstdio header and
std::remove.  One could include unistd.h, but I am not sure if that is a
reasonable assumption for all G++ targets that might want to run the G++
testsuite. 

	This patch modifies the existing testcase to include cstdio header
and changes unlink to remove.  With these changes, the testcase now passes
for me.

Okay for mainline?

	* g++.dg/opt/pr15551.C: Include cstdio.
	(main): Use remove instead of unlink.

Index: pr15551.C
===================================================================
*** pr15551.C	(revision 113190)
--- pr15551.C	(working copy)
***************
*** 7,12 ****
--- 7,13 ----
  
  #include <cstring>
  #include <fstream>
+ #include <cstdio>
  using namespace std;
  
  ostream* logfile;
*************** int main () {
*** 19,25 ****
    strcpy(expList, "foo");
  
    delete logfile;
!   unlink ("bar");
  
    return 0;
  }
--- 20,26 ----
    strcpy(expList, "foo");
  
    delete logfile;
!   remove ("bar");
  
    return 0;
  }



More information about the Gcc-patches mailing list