[Boost-bugs] [Boost C++ Libraries] #12234: boost::multiprecision x64 win32 hard compile errors on windows with mpir

Subject: [Boost-bugs] [Boost C++ Libraries] #12234: boost::multiprecision x64 win32 hard compile errors on windows with mpir
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-05-29 20:54:09


#12234: boost::multiprecision x64 win32 hard compile errors on windows with mpir
------------------------------+----------------------------
 Reporter: tlyons@… | Owner: johnmaddock
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: multiprecision
  Version: Boost 1.61.0 | Severity: Showstopper
 Keywords: mpir x64 |
------------------------------+----------------------------
 I get a hard compile error in trying to get boost multprecision
 floating point examples working with mpir on windows x64.

 The crux of the error is that some of the boost code uses functions
 whose signatures are long* but the code is used with arguments of
 type mpir_ui* etc.and of course this is a nasty for pointers!

 {{{
 1>C:\Program Files\boost\boost_1_61_0\boost/multiprecision/gmp.hpp(982):
 error C2664: 'double __gmpf_get_d_2exp(mpir_si *,mpf_srcptr)': cannot
 convert argument 1 from 'long *' to 'mpir_si *'
 1> C:\Program Files\boost\boost_1_61_0\boost/multiprecision/gmp.hpp(982):
 note: Types pointed to are unrelated; conversion requires
 reinterpret_cast, C-style cast or function-style cast
 }}}

 One workaround that "works" is to define
 double __gmpf_get_d_2exp(long * p, mpf_srcptr a) :


 {{{
 #include "stdafx.h"
 #include <boost/multiprecision/gmp.hpp>
 #include <boost/math/special_functions/gamma.hpp>
 #include "Safeint3.hpp"
 #include <iostream>
 namespace boost {
         namespace multiprecision {
                 template <unsigned Digits10>
                 struct gmp_float;
                 typedef number<gmp_float<50> > mpf_float_50;
                 typedef number<gmp_float<100> > mpf_float_100;
                 typedef number<gmp_float<500> > mpf_float_500;
                 typedef number<gmp_float<1000> > mpf_float_1000;
                 typedef number<gmp_float<0> > mpf_float;
         }
 } // namespaces

 //FIX - define a wrapper
 double __gmpf_get_d_2exp(long * p, mpf_srcptr a) {
         mpir_si temp{ *p };
         double b = __gmpf_get_d_2exp(&temp, a);
         *p = SafeInt<long>(temp);
         return b;
 }


 }}}



 But is this the answer? I find it difficult to get the sense of
 gmp.hpp well enough to figure out whether or not it knows when
 it can narrow a variable and when it cannot.

 Clearly is intended to cope with the 64 32 divide on long;
 however I am puzzled by code like:
 {{{
 inline void eval_convert_to(long* result, const gmp_rational& val)
 {
 double r;
 eval_convert_to(&r, val);
 *result = static_cast<long>(r);
 }

 inline void eval_convert_to(unsigned long* result, const gmp_rational&
 val)
 {
  double r;
  eval_convert_to(&r, val);
  *result = static_cast<long>(r);
 }

 }}}
 Which to my amateur eye does not seem to be nice.


 Suggestions welcome -
 mpir is the current version and working nicely;
 boost is 1.61.0 and working nicely.

 I would really like to get them working together.

 Environment - VS 2015-2008, Intel 16.0, windows 7.




 Terry

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12234>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC