Hi
I get segmentation fault with the following example using
CC: Sun C++ 5.8 2005/10/13
CC: Sun C++ 5.6 Patch 117549-04 2005/10/11
Should I really get segv and what can I use as workaround ( instead of sungetc ) ?
CC test.cpp && ./a.out
read bytes 9
sungetc 10
CC test.cpp -library=stlport4 && ./a.out
read bytes 9
Segmentation Fault(coredump)
file: text
QWERTYUI
file: test.cpp
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char buffer[256];
ifstream ifs( "text" );
if( ifs )
{
streambuf * sbuf = ifs.rdbuf();
int bytes = sbuf->sgetn( buffer, sizeof( buffer ) );
cout << "read bytes " << bytes << endl;
int status = sbuf->sungetc();
cout << "sungetc " << status << endl;
ifs.close();
}
}