asio :: streambuf를 사용하는 동안 문제가 발생했습니다. 클래스를 잘못 사용하고 있는지 누군가가 알 수 있기를 바랍니다. 이 예제 코드를 실행하면 segfaults가 발생합니다. 왜?boost :: asio :: streambuf를 사용하는 코드가 segfault를 발생시킵니다.
이 코드는 Windows (Visual Studio 2008)에서 작동하지만 Linux (gcc 4.4.1)에서는 작동하지 않습니다.
#include <boost/asio.hpp>
using namespace std;
int main()
{
boost::asio::streambuf Stream;
// Put 4 bytes into the streambuf...
int SetValue = 0xaabbccdd;
Stream.sputn(reinterpret_cast<const char*>(&SetValue), sizeof(SetValue));
// Consume 3 of the bytes...
Stream.consume(3);
cout << Stream.size() << endl; // should output 1
// Get the last byte...
char GetValue;
// --------- The next line segfaults the program ----------
Stream.sgetn(reinterpret_cast<char*>(&GetValue), sizeof(GetValue));
cout << Stream.size() << endl; // should output 0
return 0;
}
가능한 버그 ... – niXman
이 단지'asio :: streambuf'입니까, 아니면'std :: streambuf'도 같은 동작을 보이나요? –
코어도 버려졌습니다. 컴파일 된 코드를 얻기 위해'#include'하십시오. –
vissi