public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* help with iofstream - Exception: STATUS_ACCESS_VIOLATION when writing or reading
@ 2008-07-16 16:01 Matias Bonaventura
  2008-07-16 16:40 ` Dave Korn
  0 siblings, 1 reply; 2+ messages in thread
From: Matias Bonaventura @ 2008-07-16 16:01 UTC (permalink / raw)
  To: cygwin

Hi,

I´m trying to compile and run an application. It´s currently compiling
fine, but as soon as I run it I get the below error.
Debbugging the code I  manage to find it was failing when trying to
manipulate (read/write) a file.

I reduce the error and create a simple test case which outputs the same error:



[(!) DEBUG. Before opening the file]
[(!) DEBUG.  Before writing into the file]
57 [main] test 5664 _cygtls::handle_exceptions: Exception:
STATUS_ACCESS_VIOLATION
766 [main] test 5664 open_stackdumpfile: Dumping stack trace to
test.exe.stackdump


The test case code I´m using:
int main()
{
		cout << "[(!) DEBUG. Before opening the file]" << endl;
	    ofstream file;
	    file.open(FILE_NAME, ios::out);
	    if (file.is_open() && file.good() ){
		    cout << "[(!) DEBUG. Before writing into the file]" << endl;
		    file << "hola archivo";
		    cout << "[(!) DEBUG. After writeing into the file]" << endl;
		
		    file.close();
	    }
	
	    return 0;
}


Any idea why this could be happening? Is it a problem with my cygwin
instalation, with the compiler....?

I´m using gcc-2.95. I didn´t try with newer versions because the
application I´m trying to compile targets that compiler and won´t work
the newer.

THANKS!


--
:-) M.A.T.I.A.S. :-)

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: help with iofstream - Exception: STATUS_ACCESS_VIOLATION when writing or reading
  2008-07-16 16:01 help with iofstream - Exception: STATUS_ACCESS_VIOLATION when writing or reading Matias Bonaventura
@ 2008-07-16 16:40 ` Dave Korn
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Korn @ 2008-07-16 16:40 UTC (permalink / raw)
  To: cygwin

Matias Bonaventura wrote on 16 July 2008 17:01:

> I reduce the error and create a simple test case which outputs the same
> error: 
> 
> 
> 
> [(!) DEBUG. Before opening the file]
> [(!) DEBUG.  Before writing into the file]
> 57 [main] test 5664 _cygtls::handle_exceptions: Exception:
> STATUS_ACCESS_VIOLATION
> 766 [main] test 5664 open_stackdumpfile: Dumping stack trace to
> test.exe.stackdump
> 
> 
> The test case code I´m using:

  No it isn't.

  When I tried to compile the code you gave I get all these errors:

./fileio.cc: In function `int main()':
./fileio.cc:6: error: `cout' undeclared (first use this function)
./fileio.cc:6: error: (Each undeclared identifier is reported only once for
each function it appears in.)
./fileio.cc:6: error: `endl' undeclared (first use this function)
./fileio.cc:7: error: `ofstream' undeclared (first use this function)
./fileio.cc:7: error: expected `;' before "file"
./fileio.cc:8: error: `file' undeclared (first use this function)
./fileio.cc:8: error: `FILE_NAME' undeclared (first use this function)
./fileio.cc:8: error: `ios' has not been declared
./fileio.cc:8: error: `out' undeclared (first use this function)

... and the moral of the story is "If you want people to help you with a
problem, don't tell them lies".  Show them the REAL code, not a useless
snippet that won't compile.

> Any idea why this could be happening? Is it a problem with my cygwin
> instalation, with the compiler....?
> 
> I´m using gcc-2.95. I didn´t try with newer versions because the
> application I´m trying to compile targets that compiler and won´t work
> the newer.

  There are known to be bugs in 2.95 and in particular in 2.95's version of
the C++ runtime and STL.

  I nearly didn't bother, because I had to go look up which headers to
include and fix your non-compiling code, but I was feeling generous, so I
fixed it and built it with current gcc-3.3.3; it works fine with that.

>I didn´t try with newer versions because the
> application I´m trying to compile targets that compiler and won´t work
> the newer.

  Well, you need to have a serious think about that, because your
application clearly won't work with that older one either.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-07-16 16:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-16 16:01 help with iofstream - Exception: STATUS_ACCESS_VIOLATION when writing or reading Matias Bonaventura
2008-07-16 16:40 ` Dave Korn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).