snap-python icon indicating copy to clipboard operation
snap-python copied to clipboard

Make failing due to no matching `is_nan` function

Open JesseKolb opened this issue 7 years ago • 1 comments

I have cloned the snap-python and snap repos and confirmed that swig is installed. When I cd to the snap-python directory and run make, it fails with the following error:

In file included from ../../snap/snap-core/Snap.cpp:8:
../../snap/glib-core/linalg.cpp:708:32: error: no matching function for call to 'isnan'
                        Assert(_isnan(a(j-1,k-1)) == 0);
                               ^~~~~~~~~~~~~~~~~~
../../snap/glib-core/bd.h:46:19: note: expanded from macro '_isnan'
#define _isnan(x) isnan(x)
                  ^~~~~
../../snap/glib-core/bd.h:252:5: note: expanded from macro 'Assert'
  ((Cond) ? static_cast<void>(0) : ExeStop(NULL, NULL, #Cond, __FILE__, __LINE__))
    ^~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/math.h:464:25: note: candidate template ignored: disabled by 'enable_if' [with _A1 = TFlt]
typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
                        ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/math.h:472:25: note: candidate template ignored: disabled by 'enable_if' [with _A1 = TFlt]
typename std::enable_if<std::is_integral<_A1>::value, bool>::type

Within math.h is the following code:

// isnan

#ifdef isnan

template <class _A1>
_LIBCPP_ALWAYS_INLINE
bool
__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
{
    return isnan(__lcpp_x);
}

#undef isnan

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
isnan(_A1 __lcpp_x) _NOEXCEPT
{
    return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);
}

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_integral<_A1>::value, bool>::type
isnan(_A1) _NOEXCEPT
{ return false; }

#endif  // isnan

I also get an error with isnan when specifying make CC=gcc-7:

../../snap/glib-core/bd.h:46:26: error: no matching function for call to 'isnan(TFlt&)'
 #define _isnan(x) isnan(x)
                          ^
../../snap/glib-core/bd.h:252:5: note: in definition of macro 'Assert'
   ((Cond) ? static_cast<void>(0) : ExeStop(NULL, NULL, #Cond, __FILE__, __LINE__))
     ^~~~
../../snap/glib-core/linalg.cpp:708:32: note: in expansion of macro '_isnan'
                         Assert(_isnan(a(j-1,k-1)) == 0);
                                ^~~~~~
In file included from /usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/math.h:36:0,
                 from ../../snap/glib-core/base.h:132,
                 from ../../snap/snap-core/Snap.h:9,
                 from ../../snap/snap-core/Snap.cpp:4:
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/cmath:877:5: note: candidate: template<class _Tp> typename __gnu_cxx::__enable_if<std::__is_arithmetic<_Tp>::__value, int>::__type std::isnan(_Tp)
     isnan(_Tp __f)
     ^~~~~
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/cmath:877:5: note:   template argument deduction/substitution failed:
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/cmath: In substitution of 'template<class _Tp> typename __gnu_cxx::__enable_if<std::__is_arithmetic<_Tp>::__value, int>::__type std::isnan(_Tp) [with _Tp = TFlt]':
../../snap/glib-core/linalg.cpp:708:25:   required from here
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/cmath:877:5: error: no type named '__type' in 'struct __gnu_cxx::__enable_if<false, int>'
In file included from ../../snap/glib-core/base.h:178:0,
                 from ../../snap/snap-core/Snap.h:9,
                 from ../../snap/snap-core/Snap.cpp:4:

which has the following math.h:

  template<typename _Tp>
    inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
                                           int>::__type
    isnan(_Tp __f)
    {
      typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
      return __builtin_isnan(__type(__f));
    }

I guess it may be a compiler issue on my end since no one is experiencing this problem with isnan with the TFlt type during make, but I still can't figure out exactly what it is.

JesseKolb avatar May 01 '18 04:05 JesseKolb

Which OS and compiler are you using?

roks avatar Aug 17 '18 01:08 roks