[Boost-bugs] [Boost C++ Libraries] #13591: maybe a bug in math::constants library

Subject: [Boost-bugs] [Boost C++ Libraries] #13591: maybe a bug in math::constants library
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-06-11 14:33:52


#13591: maybe a bug in math::constants library
--------------------------+--------------------------
 Reporter: seanxnie@… | Owner: John Maddock
     Type: Bugs | Status: new
Milestone: Boost 1.67.0 | Component: math
  Version: Boost 1.67.0 | Severity: Problem
 Keywords: |
--------------------------+--------------------------
 The following templated code will generate incorrect result in visual
 studio community 2017:

 {{{
 #include<iostream>
 #include<boost/math/constants/constants.hpp>

 // convienent defination of math constants
 template<typename T> const T pi = boost::math::constants::pi<T>(); // PI
 template<typename T> const T two_pi = boost::math::constants::two_pi<T>();
 // 2*PI

 // physical constants
 template<typename T> const T mu_0 = 4.0*pi<T>*1.0e-4; // permeability of
 free space in H / km
 int main()
 {
         using T = double;
         auto w = two_pi<T> * 0.01;
         //auto t1 = pi<T>;
         auto t2 = mu_0<T>;
         std::cout<<"omega="<<w<<std::endl;
         std::cout<<"mu_0="<<t2<<std::endl;
         system("pause");

         return 0;
 }

 }}}

 In VS2017, mu_0 will be 0.000. However, if I uncomment
 {{{
 auto t1 = pi<T>
 }}}
 in main, the result is correct. This problem does not happen when compiled
 with gcc 8.1 in Manjaro Linux. The boost library version is 1.67.0

-- 
Ticket URL: <https://svn.boost.org/trac10/ticket/13591>
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 : 2018-06-11 14:40:28 UTC