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

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #13591: maybe a bug in math::constants library
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-08-18 18:28:45


#13591: maybe a bug in math::constants library
---------------------------+--------------------------
  Reporter: seanxnie@… | Owner: John Maddock
      Type: Bugs | Status: closed
 Milestone: Boost 1.67.0 | Component: math
   Version: Boost 1.67.0 | Severity: Problem
Resolution: obsolete | Keywords:
---------------------------+--------------------------

Comment (by John Maddock):

 Not sure, but I think this is an order of initialization error, with mu_0
 being initialized before pi.

 Whatever I can reduce the issue down to:

 {{{
 template <class T>
 T get_pi()
 {
    return 3.14;
 }
 template <class T>
 T get_2_pi()
 {
    return 6.28;
 }

 template<typename T> const T pi = get_pi<T>(); // PI
 template<typename T> const T two_pi = get_2_pi<T>(); // 2*PI

 // physical constants
 template<typename T> const T mu_0 = 4.0*pi<T>*1.0e-4;

 int main()
 {
    using T = double;
    auto w = two_pi<T> * 0.01;
    //auto t1 = pi<T>; // uncomment this line and everything works OK.
    auto t2 = mu_0<T>;
    std::cout << "omega=" << w << std::endl;
    std::cout << "mu_0=" << t2 << std::endl;
    system("pause");

    return 0;
 }
 }}}

 So it's not our bug if it's a bug at all?

 Note: please reply on the linked github issue as this Trac is now closed.

-- 
Ticket URL: <https://svn.boost.org/trac10/ticket/13591#comment:2>
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-08-18 18:34:22 UTC