From: Sam M. <sa...@ia...> - 2006-02-28 16:20:08
|
On Feb 28, 2006, at 7:03 AM, SourceForge.net wrote: > Index: SmartPtr.h > =================================================================== > RCS file: /cvsroot/loki-lib/loki/include/loki/SmartPtr.h,v > retrieving revision 1.21 > retrieving revision 1.22 > diff -u -d -r1.21 -r1.22 > --- SmartPtr.h 27 Feb 2006 19:59:20 -0000 1.21 > +++ SmartPtr.h 28 Feb 2006 12:59:59 -0000 1.22 > @@ -713,10 +713,10 @@ > {} > > static void OnInit(P val) > - { if (!val) throw NullPointerException(); } > + {} > > static void OnDefault(P val) > - { OnInit(val); } > + {} > > void OnDereference(P val) > { OnInit(val); } > @@ -1362,6 +1362,9 @@ > #endif // SMARTPTR_INC_ Peter, I do not think this fix is correct. You should add "if (!val) throw NullPointerException();" to both OnDereference methods. Right now they simply call OnInit, which does nothing and consequently will not throw an exception in the event of a NULL dereference. Also I got this warning from gcc when compiling with -Wextra -Wunused: /usr/local/include/loki/SmartPtr.h:715: warning: unused parameter 'val' Since the val parameter isn't used, could it be changed to "OnInit(const P&) {}"? Likewise with the OnDefault method. Thanks, Sam Miller Graduate Research Assistant Department of Electrical and Computer Engineering Iowa State University 312 Wilhelm Hall Ames Laboratory (515) 294-2148 Ames, IA - 50011 sa...@sc... http://www.scl.ameslab.gov/~samm/ |