This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
Re: seg fault with IO
- To: Phil Edwards <pedwards at jaj dot com>
- Subject: Re: seg fault with IO
- From: Gerald Gutierrez <gutier at intergate dot bc dot ca>
- Date: Sat, 13 Nov 1999 22:15:01 -0800 (PST)
- CC: libstdc++ at sourceware dot cygnus dot com
- References: <199911140135.UAA03654@jaj.com>
> There's no indication of where the program faulted, i.e., was it
> the ifstream
> constructor, or was it the read() function?
Oh, I forgot to mention that, sorry. It seems to be with the read(),
though the debugger output really tells nothing useful (at least to
me).
Program received signal SIGSEGV, Segmentation fault.
0x804c49f in main (ac=1, av=0x7ffff974) at read.cc:11
11 return 0;
(gdb) where
#0 0x804c49f in main (ac=1, av=0x7ffff974) at read.cc:11
> I assume you know that ifs.get(ch); would be an easier way to read in a
> single character, and that the code you posted is an extreme simplification
> of what you're actually trying to do. :-)
Yes it is. I'm sure it's the read statement because if I comment it
out, it compiles fine and the program runs to completion.
read(&ch,1) and get(ch) does the same thing, right? Can anyone else
reproduce this seg fault? Or is it just me ...
I'll report the source. Thanks for any help.
#include <fstream>
using namespace std;
int
main(int ac, char* av[])
{
ifstream ifs("read.cc");
char ch;
ifs.read(&ch, 1); // <-- Problem here
return 0;
}