Ticket #45210: octave-3.8.2-clang-libcxx.patch

File octave-3.8.2-clang-libcxx.patch, 3.1 KB (added by Schamschula (Marius Schamschula), 6 years ago)
  • new file liboctave/operators/libcxx-fix.h

    # HG changeset patch
    # User Kefu Chai <tchaikov@gmail.com>
    # Date 1413043255 -28800
    #      Sun Oct 12 00:00:55 2014 +0800
    # Node ID 1433cd4f7b7bda0b0e0a04f990b55ffc3cbaf701
    # Parent  91a6f06c505220d269de3a0dab8cc898d03d91a0
    fix the build error on clang 3.5 and libc++ (bug #43298)
    
    * liboctave/operators/mx-inlines.cc:
    use the workaround if libc++ with this issue is detected.
    
    * liboctave/operators/libcxx-fix.cc:
    add a workaround for http://llvm.org/bugs/show_bug.cgi?id=21083, so that only
    the arithmetic types are accepted for the function template "libcxx_fix::pow()".
    
    diff -r 91a6f06c5052 -r 1433cd4f7b7b liboctave/operators/libcxx-fix.h
    - +  
     1#ifndef _LIBCPP_VERSION
     2#error "for libc++ only"
     3#endif
     4
     5namespace libcxx_fix {
     6
     7using std::is_integral;
     8using std::is_same;
     9using std::enable_if;
     10
     11template <class _Tp, class _Tn = void>
     12struct numeric_type
     13{
     14    typedef void type;
     15    static const bool value = false;
     16};
     17
     18template <class _Tp>
     19struct numeric_type<_Tp, typename enable_if<is_integral<_Tp>::value ||
     20                                            is_same<_Tp, double>::value>::type>
     21{
     22    typedef double type;
     23    static const bool value = true;
     24};
     25
     26template <class _Tp>
     27struct numeric_type<_Tp, typename enable_if<is_same<_Tp, long double>::value ||
     28                                            is_same<_Tp, float>::value>::type>
     29{
     30    typedef _Tp type;
     31    static const bool value = true;
     32};
     33
     34template <>
     35struct numeric_type<void, void>
     36{
     37    static const bool value = true;
     38};
     39
     40template <class _A1, class _A2,
     41          bool = numeric_type<_A1>::value &&
     42                 numeric_type<_A2>::value>
     43class promote
     44{};
     45
     46template <class _A1, class _A2>
     47class promote<_A1, _A2, true>
     48{
     49private:
     50    typedef typename numeric_type<_A1>::type __type1;
     51    typedef typename numeric_type<_A2>::type __type2;
     52public:
     53    typedef decltype(__type1() + __type2()) type;
     54};
     55
     56template <class _A1, class _A2>
     57inline _LIBCPP_INLINE_VISIBILITY
     58typename promote<_A1, _A2>::type
     59pow(_A1 __x, _A2 __y) _NOEXCEPT
     60{
     61    typedef typename promote<_A1, _A2>::type __result_type;
     62#if _LIBCPP_STD_VER > 11
     63    static_assert((!(is_same<_A1, __result_type>::value &&
     64                     is_same<_A2, __result_type>::value)), "");
     65#endif
     66    return ::pow(static_cast<__result_type>(__x), static_cast<__result_type>(__y));
     67}
     68
     69}
  • liboctave/operators/mx-inlines.cc

    diff -r 91a6f06c5052 -r 1433cd4f7b7b liboctave/operators/mx-inlines.cc
     
    306306
    307307// Let the compiler decide which pow to use, whichever best matches the
    308308// arguments provided.
     309#if defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION >= 1101)
     310// Workaround http://llvm.org/bugs/show_bug.cgi?id=21083
     311#include "libcxx-fix.h"
     312using libcxx_fix::pow;
     313#else
    309314using std::pow;
     315#endif
    310316DEFMXMAPPER2X (mx_inline_pow, pow)
    311317
    312318// Arbitrary function appliers. The function is a template parameter to enable