[vtk-developers] Use of assert

tom fogal tfogal at apollo.sr.unh.edu
Thu Jul 21 14:10:53 EDT 2005


 <42DFDA87.2020702 at kitware.com>David Cole writes:
>Perhaps there should be a "VTK_ASSERT" wrapper that gets used within VTK 
>proper...? That way we can control whether an abort happens or not, at 
>least for the ones that are in VTK source.

I won't comment on my opinions on assert =) but I do know that on linux
systems (probably all glibc systems?), if NDEBUG is defined asserts are
preprocessed out.

I suspect that this is relatively standard, and would thus recommend
that VTK use that if it is decided to conditionally use asserts, based
on the build type.

-tom

<snip>

>Mathieu Malaterre wrote:
>
>>Ken,
>>
>>   Since I am responsible for most of the undocumented assert in the XML-IO stuff, here are my thoughts. According to Berk application like ParaView can be build in Debug mode (me
>aning with assert enable). He believes that ParaView should not ever abort on purpose. 
>>
>>   Most of the assert are checking that the inputs are correct for the functions. There are still some other assert that check nothing 'impossible' is happening. That was and stil
>l is pretty usefull for debuging. For instance I was not reinitializing the array when the user was reusing the same writer. The assert caught it right away, the bug was solved alm
>ost immediately.
>>
>>   Therefore the question is what should one do with those type of assert when something new is added to VTK and hasn't been tested for a long time ?
>>
>>   BTW what kind of user on purpose build ParaView in Debug mode ? What are your comment on the above, and on the fact that your application could abort ?
>>
>>Thanks,
>>Mathieu
>>
>>  
>>
>>>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
>>>
>>>    
>>>
>>
>>_______________________________________________
>>vtk-developers mailing list
>>vtk-developers at vtk.org
>>http://www.vtk.org/mailman/listinfo/vtk-developers
>>
>>  
>>
>_______________________________________________
>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