[Insight-developers] VS6 warnings in Review are probably errors

Bill Lorensen bill.lorensen at gmail.com
Fri Feb 20 19:53:15 EST 2009


I retract my last comment:
Also, the initVector method creates a vector of a very large size:
   m_Vector.resize( static_cast<int>( NumericTraits< TInputPixel
>::max() - NumericTraits< TInputPixel >::NonpositiveMin() + 1 ), 0 );

I see now, that the algorithm is not used for types (like int) that
have large max() values. I think my other comments about overflow
still hold.

Bill

On Fri, Feb 20, 2009 at 7:49 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> Gaetan,
>
> My VS6 build gives the following warnings:
> C:\Projects\Insight\Code\Review\itkMovingHistogramImageFilter.txx(49)
> : warning C4756: overflow in constant arithmetic
> C:\Projects\Insight\Code\Review\itkMovingHistogramImageFilter.txx(49)
> : warning C4756: overflow in constant arithmetic
> C:\Projects\Insight\Code\Review\itkMovingHistogramMorphologyImageFilter.h(34)
> : warning C4756: overflow in constant arithmetic
> C:\Projects\Insight\Code\Review\itkMovingHistogramMorphologyImageFilter.h(40)
> : warning C4756: overflow in constant arithmetic
> C:\Projects\Insight\Code\Review\itkMovingHistogramMorphologyImageFilter.h(34)
> : warning C4756: overflow in constant arithmetic
> C:\Projects\Insight\Code\Review\itkMovingHistogramMorphologyImageFilter.h(40)
> : warning C4756: overflow in constant arithmetic
> C:\Projects\Insight\Code\Review\itkAnchorHistogram.h(135) : warning
> C4756: overflow in constant arithmetic
> C:\Projects\Insight\Code\Review\itkAnchorHistogram.h(135) : warning
> C4756: overflow in constant arithmetic
>
> For example, in itkAcnchorHistogram.h:
>  m_Size = static_cast<unsigned int>( NumericTraits< TInputPixel >::max() -
>                                        NumericTraits< TInputPixel
>>::NonpositiveMin() + 1 );
> will overflow for types that have NonpositiveMin() = 0 since max() + 1
> overflows.
>
> Also, these some of these classes have non-standard method names that
> start with lower case letters (e.g.
> MovingHistogramMorphologyImageFilter has a method named
> useVectorBasedAlgorithm. This should be UseVectorBasedAlgorithm. Also
> initVector which should be InitializeVector.
>
> Also, the initVector method creates a vector of a very large size:
>    m_Vector.resize( static_cast<int>( NumericTraits< TInputPixel
>>::max() - NumericTraits< TInputPixel >::NonpositiveMin() + 1 ), 0 );
>
> Bill
>


More information about the Insight-developers mailing list