[Insight-developers] ICE on vs6.0

Bradley Lowekamp blowekamp at mail.nih.gov
Thu Apr 1 13:04:45 EDT 2010


Darn,

I missed that change! Thanks for finding it. The planned implementation of CastWithRangeCheck is:


template <typename TReturn,typename TInput>
inline TReturn CastWithRangeCheck(TInput x)
{
  itkConceptMacro( OnlyDefinedForIntegerTypes1, (itk::Concept::IsInteger<TReturn>) );
  itkConceptMacro( OnlyDefinedForIntegerTypes2, (itk::Concept::IsInteger<TInput>) );
  TReturn ret = static_cast<TReturn>(x);
  if ( sizeof (TReturn) > sizeof(TInput) && 
       !( !NumericTraits<TReturn>::is_signed &&  NumericTraits<TInput>::is_signed ) )
    {
    // if the output type is bigger and we are not converting a signed
    // interger to an unsigned interger then we have no problems
    return ret;
    }
  else if ( ret != x ||
       ( NumericTraits<TInput>::IsPositive(x) != NumericTraits<TReturn>::IsPositive(ret) ) )
    {
    // this should likely be a new exception class
    RangeError _e(__FILE__, __LINE__);
    throw _e;
    }
  return ret;
}

So while it is not needed now, currently it looks like it will be in the future.

The other issue with the code is the comparison "ret != x". This is correct and is exactly as it needs to be, as it relies on the default promotion of types, and default behavior for comparing signed and unsigned integer types. Unfortunately it generates a warning, and there is not simple explicit casting which will follow the default promotion rules.

Brad

On Apr 1, 2010, at 12:11 PM, Bill Lorensen wrote:

> Brad,
> 
> Actually, you also added
> #include "itkConceptChecking.h"
> to
> itkMath.h
> 
> If I remove that, the ICE goes away.
> 
> Why was that include added? Can I remove it?
> 
> Bill
> 
> On Wed, Mar 31, 2010 at 8:33 AM, Bradley Lowekamp
> <blowekamp at mail.nih.gov> wrote:
>> Hello,
>> Yesterday I committed these innocent changes to comments:
>> http://www.cdash.org/CDash/viewUpdate.php?buildid=574645
>> Then both the continuous and the night vs60 build generated ICEs:
>> http://www.cdash.org/CDash/viewBuildError.php?buildid=574645
>> I have no clue on this one!
>> Thanks,
>> Brad
>> 
>> ========================================================
>> 
>> Bradley Lowekamp
>> 
>> Lockheed Martin Contractor for
>> 
>> Office of High Performance Computing and Communications
>> 
>> National Library of Medicine
>> 
>> blowekamp at mail.nih.gov
>> 
>> 
>> _______________________________________________
>> 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/20100401/24d79d5c/attachment.htm>


More information about the Insight-developers mailing list