[vtk-developers] Use of assert

Chris Volpe cvolpe at ara.com
Thu Jul 21 10:21:50 EDT 2005


This might be a symptom of a larger problem, that is, misusing
assertions as a way of replacing user input validation. Bad input should
be handled at the function level with return codes, and at the
application level with an error dialog box, even in release code, where
an assertion becomes a no-op. A failed assertion should be an indicator
of a *bug* in the code containing the assertion, not an indicator of bad
input. 

Well, that's what *I've* always understood the purpose to be. I could be
wrong.
 
Chris
 
--
Christopher R. Volpe, Ph.D. 
Senior Scientist                       Email: cvolpe at ara.com
Applied Research Associates, Inc.        Voice: 919-582-3380
8540 Colonnade Center Dr., Ste 301         Fax: 919-878-3672 
Raleigh, NC 27615                           Web: www.ara.com
 
 > -----Original Message-----
> From: vtk-developers-bounces+cvolpe=ara.com at vtk.org [mailto:vtk-
> developers-bounces+cvolpe=ara.com at vtk.org] On Behalf Of Ken Martin
> Sent: Thursday, July 21, 2005 10:03 AM
> To: vtk-developers at vtk.org
> Subject: [vtk-developers] Use of assert
> 
> Since I am seeing more use of assert in VTK, such as...
> 
>     assert(numPieces > 0);
> 
> is there a reason why we shouldn't require that people comment their
> assert
> statements? For example the above assert should be
> 
> assert(numPieces > 0 && "OffsetGroupManager allocation requested for
> numPieces <= 0")
> 
> I think on most systems if the debugger is not invoked the content of
the
> assert will be displayed at least. Am I missing something?
> 
> Thanks
> Ken
> 
> 
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at vtk.org
> http://www.vtk.org/mailman/listinfo/vtk-developers



More information about the vtk-developers mailing list