[Insight-users] Visual Studio 2012 ITK-4.4.0 assert failed on TransformType::New();

John Drescher drescherjm at gmail.com
Thu Jun 20 16:47:37 EDT 2013


I have hit an assert failed apparently due to the usage if 0 as an
iterator and the VS builtin checked iterators. The following simple
program will assert when run in Visual Studio 2012 in debug mode ( I
did not try other modes).

// main.cxx

#include <itkIdentityTransform.h>

int main(int, char*[])
{
	typedef itk::IdentityTransform< double, 3 >				TransformType;
	
	// The following line will assert in Visual Studio 2012 with checked iterators
	TransformType::Pointer transform = TransformType::New();
	
}

// CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project ( TestItkIdentityTransform )

find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

add_executable( ${PROJECT_NAME} main.cxx )

target_link_libraries( ${PROJECT_NAME} ${ITK_LIBRARIES} )


The problem is with

template <class T>
vnl_matrix<T>& vnl_matrix<T>::fill (T const& value)


template <class T>
vnl_matrix<T>& vnl_matrix<T>::fill (T const& value)
{
  // not safe if data == NULL, due to data[0] call
  if (data)
    vcl_fill_n( this->data[0], this->num_rows * this->num_cols, value );
  return *this;
}

in when it executes  this->data[0] == 0 and this causes VS to assert
with "invalid null pointer"  even though this->num_rows *
this->num_cols is also 0.

John


More information about the Insight-users mailing list