[Insight-developers] MedialNodeCorrespondencesTest, Intel C++ fixed

Bill Hoffman bill . hoffman at kitware . com
Thu, 14 Aug 2003 13:58:35 -0400


This change was made so that the fixed versions did not have the overhead
of having the extra data associated with the non-fixed versions.  (8 bytes)


 From what I can tell, you are saying that the following crashes:


#include <vnl/vnl_matrix.h>
#include <vnl/vnl_matrix_fixed.h>
void foo(vnl_matrix<double> m)
{
  vnl_matrix<double> mm = m;
}

main()
{
  vnl_matrix_fixed<double,3,3> m;
  foo(m);
  return 0;
}

Which intel compiler is this?  Windows or Linux?

It is using this operator:

  //: Cheap conversion to vnl_matrix_ref
  // Sometimes, such as with templated functions, the compiler cannot
  // use this user-defined conversion. For those cases, use the
  // explicit as_ref() method instead.
  operator const vnl_matrix_ref<T>() const { return vnl_matrix_ref<T>( num_rows, num_cols, const_cast<T*>(data_block()) ); }

Sounds like a bug in the compiler.   This is going to be hard to track down in all the
code, and should work.  

If you let me know which intel compiler it is crashing on, I can take a look.

-Bill


>It looks like the vnl_matrix_fixed and vnl_matrix classes are no longer related via inheritence.  Instead, there are some converter routines ( mat_fixed.as_ref() returns a vnl_matrix).  
> 
>The Intel compiler builds were crashing on the deallocation of a vnl_matrix.  Bill changed the code in Ellipsoid*SpatialFunction to take a reference to a vnl_matrix_fixed instead of taking a vnl_matrix by value.  This clears up the problem on the Intel compiler.  I am guessing the other systems are relying on some other type conversion operators that may be flawed on the Intel compiler.
> 
>Two things to look out for:
> 
>1. vnl_matrix and vnl_matrix_fixed mismatches.
>2. function that take matrix types by value as opposed to by reference. 
>