2006/10/24, Marco Jez <[EMAIL PROTECTED]>:
ok, I don't know this but it work well.
Hi David,
reading a pointer from a stream fails if the stream doesn't contain a valid
decimal or hexadecimal number (which can be converted to a pointer address).
This is the behaviour of the STL.
ok, I don't know this but it work well.
That's correct. And now I'm really puzzled. According to my debugger, the
exception is being raised because the second line of ptype() tries to get
the type of a dereferenced null pointer. But if the pointer is null, how can
it pass the test in the first line? Perhaps the debugger is wrong, I mean
the pointer is not null but it points to garbage data, or maybe this is just
the result of some memory corruption... This is even worse.
It's not your debugger, its the value in the string to convert:
in the jose test, the string contain "fonts/arial.ttf"
and the first f is take than a hexadecimal number and so past the stream test.
see the joint file.
Best Regards
David
// ** g++ -Wall -W io_ptr_test.cpp -o io_ptr_test
#include <iostream>
#include <sstream>
#include <string>
void test(std::string str)
{
std::cout << "do the test with " << str << std::endl;
std::stringstream ss;
void * ptr;
ss << str;
ss >> ptr;
if (ss)
std::cout << "ss is true" << std::endl;
else
std::cout << "ss is false" << std::endl;
std::cout << "ss = " << ss.str() << std::endl;
std::cout << "ptr = " << ptr << std::endl << std::endl;
}
int main(int /*argc*/, char** /*argv*/)
{
test("10");
test("0x10");
test("file");
test("toto");
test("marco");
return 0;
}
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
