[Insight-developers] itk::Array has an implicit conversion from unsigned int????

Bradley Lowekamp blowekamp at mail.nih.gov
Wed Mar 10 13:55:16 EST 2010


I ran int to this before! 

I believe I encountered it utilizing the new ITK Statistics, when trying to set the size of perhaps a histogram. It expected an array but I used a integer which got converted into some high dimension itk::Array. Initializing a histogram with 256 dimension with zero bins in each dimension. Needless to say it caused my program to crash, and after a fair amount of time I tracked it down. Since I have been using the following:

Index: itkArray.h
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/Common/itkArray.h,v
retrieving revision 1.47
diff -r1.47 itkArray.h
60c60
<   Array(unsigned int dimension);
---
>   explicit Array(unsigned int dimension);


I didn't audit other array types to ensure that this insidious  implicit constructor isn't else where. But I have been building ITK with it for a while and the explicit qualifier does not cause any problems else where.

Brad


On Mar 10, 2010, at 1:40 PM, kent williams wrote:

> I ran into this today.  I thought I was dealing with a drop-in replacement
> ITK class, but the old class defined a method/member variable like this:
> 
> itkSetMacro( MaximumNumberOfIterations, unsigned int);
> 
> and the new class did this:
> 
> itkSetMacro( MaximumNumberOfIterations, itk::Array<unsigned int>);
> 
> The unexpected thing was that this:
> 
> x->SetMaximumNumberOfIterations(50);
> 
> compiled without complaint.
> 
> When I debugged it, it turns out the second case is equivalent to
> 
> itk::Array<unsigned int> anonymousTemp(50);
> x->SetMaximumNumberOfIterations(anonymousTemp);
> 
> My reaction when I discovered this was WTF? (or What the Frumious
> Bandersnatch).
> 
> Where is the implicit conversion from unsigned int to itk::Array, and is
> this even a desirable thing?
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.html
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers

========================================================
Bradley Lowekamp  
Lockheed Martin Contractor for
Office of High Performance Computing and Communications
National Library of Medicine 
blowekamp at mail.nih.gov


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20100310/abd5024c/attachment.htm>


More information about the Insight-developers mailing list