Skip to main content
GameDev.net gamedev.net
🔒 Locked

null class pointer exception

Started by psykr Oct 19, 2003 at 5:42 PM 2 replies 350+ views
Original Post
psykr
psykr
What''s the exception that gets thrown when I do something like:
CFoo* pFoo = 0;
pFoo->Member(); 
I''m trying to figure out what exception to catch.
Matsen
Matsen
EXCEPTION_ACCESS_VIOLATION (SEH) on Windows, if Member() is virtual or tries to operate on the this pointer.
Sneftel
Sneftel
No exception is usually thrown by the call itself, as long as it''s not a virtual function. If it is a virtual function, there''s a segfault from trying to read a memory location very close to 0. If it isn''t, there will be the same sort of segfault if and only if the function accesses nonstatic member variables.


How appropriate. You fight like a cow.
Shannon Barber
Shannon Barber
I think you have to use platform specific code; I''ve been meaning to look into this for a couple of years now...

You can use catch(...) after catch(std::exception&) to catch non-C++ exceptions.
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.