How should we deal with access to zero pointers?

When writing code that *could* access a zero pointer, should one do the following: 1. Nothing 2. assert 3. Exception. In that case which one? My guess would be 1 since an access violation exception will be thrown any way (on VC++ at least), but now I'm not sure? Regards, Asger Mangaard

"Asger Mangaard" <tmb@tmbproductions.com> writes:
When writing code that *could* access a zero pointer, should one do the following:
1. Nothing 2. assert 3. Exception. In that case which one?
My guess would be 1 since an access violation exception will be thrown any way (on VC++ at least), but now I'm not sure?
This isn't really a Boost/library design question, is it? Maybe you should try comp.lang.c++ or comp.lang.c++.moderated. -- Dave Abrahams Boost Consulting www.boost-consulting.com

David Abrahams wrote:
"Asger Mangaard" <tmb@tmbproductions.com> writes:
When writing code that *could* access a zero pointer, should one do the following:
1. Nothing 2. assert 3. Exception. In that case which one?
My guess would be 1 since an access violation exception will be thrown any way (on VC++ at least), but now I'm not sure?
This isn't really a Boost/library design question, is it? Maybe you should try comp.lang.c++ or comp.lang.c++.moderated.
Well, it may have relevance with regard to smart pointers provided by boost libraries. Should the way this situation is handled in boost libraries be standardized / has it been already? -Jason
participants (3)
-
Asger Mangaard
-
David Abrahams
-
Jason Hise