[Insight-developers] itkAnchorHistogram: warning C4756: overflow in constant arithmetic :

Luis Ibanez luis.ibanez at kitware.com
Fri Apr 10 12:43:31 EDT 2009


Hi Gaetan,

The class:   itkAnchorHistogram

is producing a warning that looks like a real arithmetical problem.

http://www.cdash.org/CDash/viewBuildError.php?type=1&buildid=309595

It is  in Insight/Code/Review/itkAnchorHistogram.txx lines 134-135

    m_Size = static_cast<unsigned int>(

        NumericTraits< TInputPixel >::max() -
        NumericTraits< TInputPixel >::NonpositiveMin() + 1 );

Depending on the TInputPixel type, the range of max - min +1
may exceed the capacity of that unsigned integer.

In particular: Longs, Floats, and Doubles may result in integer
overflows here.


Could you suggest an alternative expression that may work
for any pixel type ?


   Thanks


       Luis


More information about the Insight-developers mailing list