[Insight-developers] BOOST_FUNCTION_COMPARE_TYPE_ID

Mathieu Malaterre mathieu.malaterre at gmail.com
Thu Nov 29 11:44:15 EST 2007


Hi there,

  I have been struggling for a while today tracking down a bug on
debian stable/gcc 3.3.5 (loading the shared lib from python).
Basically there is a bug in the operator== for std::type_info (as far
as I understand), which prevent the following code from ImageIOBase to
work correclty (*). I found a reference in the boost code, so I assume
there has been some version of gcc that suffered from it:

$ cat boost/function/function_base.hpp
// Borrowed from Boost.Python library: determines the cases where we
// need to use std::type_info::name to compare instead of operator==.
# if (defined(__GNUC__) && __GNUC__ >= 3) \
 || defined(_AIX) \
 || (   defined(__sgi) && defined(__host_mips))
#  include <cstring>
#  define BOOST_FUNCTION_COMPARE_TYPE_ID(X,Y) \
     (std::strcmp((X).name(),(Y).name()) == 0)
# else
#  define BOOST_FUNCTION_COMPARE_TYPE_ID(X,Y) ((X)==(Y))
#endif


so the question is: the bug never showed up on *any* dashboards, is it
still a reasonable patch to apply ?
And for reference the image was itk::Image< itk::Vector<float, 3>, 3>.

Thanks
-Mathieu

(*)
template <typename T>
bool
itkSetPixelType(ImageIOBase *This,
                const std::type_info &ptype,
                ImageIOBase::IOComponentType ntype,
                T itkNotUsed( dummy ) )
{
  if( ptype == typeid(T) )
    {
    This->SetNumberOfComponents(1);
    This->SetComponentType(ntype);
    This->SetPixelType(ImageIOBase::SCALAR);
    return true;
    }
...

-- 
Mathieu


More information about the Insight-developers mailing list