[numeric/interval.hpp] compilation on clang++ vs g++

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[numeric/interval.hpp] compilation on clang++ vs g++

Boost - Users mailing list
This may be a somewhat newbie question.
This is cross-posted on stack exchange before I found this list.
     (https://stackoverflow.com/questions/51062374/different-behavior-with-enable-if-using-clang-and-g)

I'm having trouble compiling the following piece of boost-based code:

*****

    #include <boost/numeric/interval.hpp>
    #include <complex>

    int main(){
      std::complex<boost::numeric::interval<double> > my_interval(1,1);
      my_interval *= my_interval;
      return 0;}

*****

When I compile using g++ (MacPorts gcc5 5.5.0_1), I get no compilation errors (g++ -std=c++14 main.cpp).

When I compile using clang++ (Apple LLVM version 8.1.0 (clang-802.0.38)), I get compilation errors (clang++ -std=c++14 main.cpp).

Summarizing the error, it appears that an enable_if in cmath (line 424: std::enable_if<std::is_arithmetic<_A1>::value, bool>::type) is preventing isnan from being defined for boost::numeric::interval<double> (at least in clang++).

Am I doing something wrong or is there a work around?  I realize that this might be more of a std::complex question than a boost question, but since it involves boost, I thought that I'd ask here.

Thank you.  The full and complete error is below.

*****

Full and Complete Error:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/complex:599:9: error: 
      no matching function for call to 'isnan'
    if (isnan(__x) && isnan(__y))
        ^~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/complex:312:27: note: 
      in instantiation of function template specialization
      'std::__1::operator*<boost::numeric::interval<double,
      boost::numeric::interval_lib::policies<boost::numeric::interval_lib::rounded_math<double>,
      boost::numeric::interval_lib::checking_strict<double> > > >' requested
      here
            *this = *this * complex(__c.real(), __c.imag());
                          ^
main.cpp:6:15: note: in instantiation of function template specialization
      'std::__1::complex<boost::numeric::interval<double,
      boost::numeric::interval_lib::policies<boost::numeric::interval_lib::rounded_math<double>,
      boost::numeric::interval_lib::checking_strict<double> > >
      >::operator*=<boost::numeric::interval<double,
      boost::numeric::interval_lib::policies<boost::numeric::interval_lib::rounded_math<double>,
      boost::numeric::interval_lib::checking_strict<double> > > >' requested
      here
  my_interval *= my_interval;
              ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:424:25: note: 
      candidate template ignored: disabled by 'enable_if' [with _A1 =
      boost::numeric::interval<double,
      boost::numeric::interval_lib::policies<boost::numeric::interval_lib::rounded_math<double>,
      boost::numeric::interval_lib::checking_strict<double> > >]
typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [numeric/interval.hpp] compilation on clang++ vs g++

Boost - Users mailing list
On Wed, Jun 27, 2018 at 6:22 AM, M B via Boost-users <[hidden email]> wrote:
This may be a somewhat newbie question.
This is cross-posted on stack exchange before I found this list.


I've responded over on SO as well, but the problem is that boost::numeric::interval is instantiating 
std::complex with a user-defined type, and the standard gives no assurances that this will work.

[complex.numbers]/2 says:

The effect of instantiating the template complex for any type other than float, double, or long double is unspecified.

-- Marshall
 

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users