C++ ofstream issue while compiling with pgcpp.


I have a very irritating issue while running a C++ application. I am using the pgcpp compiler on the Interix subsystem of Windows Xp. My problem is essentially described here:

I have a class definition in a header file. This header file is included in one source file. This class has two constructors and is basically used to implement a logger. The first constructor takes ostream *out as an argument, while the second overloaded constructor takes a filename and a default boolean value of false. The objective of this second constructor is to get a stream for the filename that we are passing and to start logging messages to it. The code in the constructors is as follows:

MessageLogger::MessageLogger (std::ostream *out)
: p_out (out), p_ofstream (0), p_indent_level (0)
if (p_out)
(*p_out) << “Started logging messages” << endl;

MessageLogger::MessageLogger (char const *filename, bool append_to_file)
: p_out (0), p_ofstream (0), p_indent_level (0)
if (append_to_file)
p_ofstream = new std::ofstream (filename, ios::app);
p_ofstream = new std::ofstream (filename);

p_out = p_ofstream;
if (p_out)
(*p_out) << “Started logging messages” << endl;

Where the declarations of p_out and p_ofstream are as follows:

std::ostream *p_out;
std::ofstream *p_ofstream;
unsigned int p_indent_level;

All the three mentioned above are private members. The instantiation of the MessageLogger class is done as:

MessageLogger logger (“filename”); Please note that append_to_file has a default value of false. PGDBG is also misbehaving. I am inexplicably able to step in when the control is at p_ofstream = new std::ofstream (filename); and it steps into a random location and then the application crashes.

Also, when I try to see either of Mixed or Disassembly code in PGDBG, the debugger crashes with the message:

jpgdbg parse: Newline must follow cmd in 'eleq “0” struct MessageLogger *MessageLogger::MessageLogger(struct basic_ostream *out); (TranslatorGeneric.cpp

jpgdbg jpgdbgFileSelector processMsg: Warning unexpected msg token 5
jpgdbg parse: Newline must follow cmd in 'eleq “1” struct MessageLogger *MessageLogger::MessageLogger(char *filename, unsigned char append_to_file); (Tr

jpgdbg jpgdbgFileSelector processMsg: Warning unexpected msg token 5

I am unable to reproduce this in a sample program where I did the exact same thing as above but everything works fine. Can someone please explain what is happening and if there is a fix to this?



The error message that you report that the debugger is generating indicates an internal debugger error. We do have any previous reports of this problem, so we do not have a fix at this time. I will enter this into our issue-tracking system; if you would like to keep up to date on this issue please contact trs@pgroup.com.

What PGI release are you running?

Which version of interix are you using (e.g. SFU, SUA-32, SUA-64).



Thanks for the reply. We are using SFU 3.5 and our PGI release version is 7.2-1.

I will keep in touch with you via the mail id provided.