From 700ea50732fb745e76cc0a917e04486858025990 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sat, 22 Sep 2007 17:00:29 +0000 Subject: [PATCH] Fixes for VC-7.1. [SVN r39478] --- include/boost/math/tools/config.hpp | 10 ++++++++++ test/Jamfile.v2 | 2 ++ test/compile_test/instantiate.hpp | 1 + test/test_bessel_i.cpp | 2 ++ test/test_bessel_k.cpp | 2 ++ test/test_bessel_y.cpp | 2 ++ test/test_ellint_2.cpp | 2 ++ test/test_gamma.cpp | 4 ++++ test/test_hermite.cpp | 4 ++++ test/test_igamma.cpp | 4 ++++ test/test_igamma_inv.cpp | 4 ++++ test/test_igamma_inva.cpp | 2 ++ test/test_laguerre.cpp | 4 ++++ test/test_tgamma_ratio.cpp | 2 ++ vc71_fix/Jamfile.v2 | 6 ++++++ vc71_fix/instantiate_all.cpp | 29 +++++++++++++++++++++++++++++ 16 files changed, 80 insertions(+) create mode 100644 vc71_fix/Jamfile.v2 create mode 100644 vc71_fix/instantiate_all.cpp diff --git a/include/boost/math/tools/config.hpp b/include/boost/math/tools/config.hpp index 323c1160e..498c9d68d 100644 --- a/include/boost/math/tools/config.hpp +++ b/include/boost/math/tools/config.hpp @@ -3,6 +3,7 @@ #include // for boost::uintmax_t #include +#include #include // for min and max #include @@ -11,6 +12,15 @@ #if defined(__CYGWIN__) || defined(__FreeBSD__) # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS #endif + +#if BOOST_WORKAROUND(BOOST_MSVC, < 1400) +// +// Define if constants too large for a float cause "bad" +// values to be stored in the data, rather than infinity +// or a suitably large value. +// +# define BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS +#endif // // Tune performance options for specific compilers: // diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index de0067f31..bbd63e6db 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -23,6 +23,7 @@ project msvc:/wd4510 msvc:/wd4127 msvc:/wd4701 # needed for lexical cast - temporary. + msvc-7.1:../vc71_fix//vc_fix # msvc:/wd4506 has no effect? # suppress xstring(237) : warning C4506: no definition for inline function ../../.. @@ -196,3 +197,4 @@ compile compile_test/tools_toms748_solve_inc_test.cpp ; + diff --git a/test/compile_test/instantiate.hpp b/test/compile_test/instantiate.hpp index 8e32eb1c7..2bd5c91a7 100644 --- a/test/compile_test/instantiate.hpp +++ b/test/compile_test/instantiate.hpp @@ -154,6 +154,7 @@ void instantiate(RealType) boost::math::legendre_next(2, 2, v1, v2, v3); boost::math::laguerre(1, v1); boost::math::laguerre(2, 1, v1); + boost::math::laguerre(2u, 1u, v1); boost::math::laguerre_next(2, v1, v2, v3); boost::math::laguerre_next(2, 1, v1, v2, v3); boost::math::hermite(1, v1); diff --git a/test/test_bessel_i.cpp b/test/test_bessel_i.cpp index 5bcfdb43e..c37c1ca7e 100644 --- a/test/test_bessel_i.cpp +++ b/test/test_bessel_i.cpp @@ -258,7 +258,9 @@ int test_main(int, char* []) #endif expected_results(); +#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS test_bessel(0.1F, "float"); +#endif test_bessel(0.1, "double"); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS test_bessel(0.1L, "long double"); diff --git a/test/test_bessel_k.cpp b/test/test_bessel_k.cpp index 826e7ab3e..46d5fc82c 100644 --- a/test/test_bessel_k.cpp +++ b/test/test_bessel_k.cpp @@ -244,7 +244,9 @@ int test_main(int, char* []) #endif expected_results(); +#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS test_bessel(0.1F, "float"); +#endif test_bessel(0.1, "double"); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS test_bessel(0.1L, "long double"); diff --git a/test/test_bessel_y.cpp b/test/test_bessel_y.cpp index a7e50e26e..37e3e4a3f 100644 --- a/test/test_bessel_y.cpp +++ b/test/test_bessel_y.cpp @@ -399,7 +399,9 @@ int test_main(int, char* []) #endif expected_results(); +#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS test_bessel(0.1F, "float"); +#endif test_bessel(0.1, "double"); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS test_bessel(0.1L, "long double"); diff --git a/test/test_ellint_2.cpp b/test/test_ellint_2.cpp index 1467be61b..968cd122a 100644 --- a/test/test_ellint_2.cpp +++ b/test/test_ellint_2.cpp @@ -187,7 +187,9 @@ void test_spots(T, const char* type_name) int test_main(int, char* []) { expected_results(); +#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS test_spots(0.0F, "float"); +#endif test_spots(0.0, "double"); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS test_spots(0.0L, "long double"); diff --git a/test/test_gamma.cpp b/test/test_gamma.cpp index b25d18802..2d2c43ec3 100644 --- a/test/test_gamma.cpp +++ b/test/test_gamma.cpp @@ -431,14 +431,18 @@ int test_main(int, char* []) { expected_results(); +#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS test_spots(0.0F); +#endif test_spots(0.0); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS test_spots(0.0L); test_spots(boost::math::concepts::real_concept(0.1)); #endif +#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS test_gamma(0.1F, "float"); +#endif test_gamma(0.1, "double"); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS test_gamma(0.1L, "long double"); diff --git a/test/test_hermite.cpp b/test/test_hermite.cpp index e0210a24e..2a2f3330f 100644 --- a/test/test_hermite.cpp +++ b/test/test_hermite.cpp @@ -173,7 +173,9 @@ void test_spots(T, const char* t) int test_main(int, char* []) { +#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS test_spots(0.0F, "float"); +#endif test_spots(0.0, "double"); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS test_spots(0.0L, "long double"); @@ -182,7 +184,9 @@ int test_main(int, char* []) expected_results(); +#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS test_hermite(0.1F, "float"); +#endif test_hermite(0.1, "double"); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS test_hermite(0.1L, "long double"); diff --git a/test/test_igamma.cpp b/test/test_igamma.cpp index 5eb0c8855..6846cd904 100644 --- a/test/test_igamma.cpp +++ b/test/test_igamma.cpp @@ -442,7 +442,9 @@ int test_main(int, char* []) { expected_results(); +#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS test_spots(0.0F); +#endif test_spots(0.0); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS test_spots(0.0L); @@ -451,7 +453,9 @@ int test_main(int, char* []) #endif #endif +#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS test_gamma(0.1F, "float"); +#endif test_gamma(0.1, "double"); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS test_gamma(0.1L, "long double"); diff --git a/test/test_igamma_inv.cpp b/test/test_igamma_inv.cpp index 1f4d64563..1548e53fe 100644 --- a/test/test_igamma_inv.cpp +++ b/test/test_igamma_inv.cpp @@ -365,7 +365,9 @@ int test_main(int, char* []) { expected_results(); +#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS test_spots(0.0F, "float"); +#endif test_spots(0.0, "double"); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS test_spots(0.0L, "long double"); @@ -374,7 +376,9 @@ int test_main(int, char* []) #endif #endif +#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS test_gamma(0.1F, "float"); +#endif test_gamma(0.1, "double"); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS test_gamma(0.1L, "long double"); diff --git a/test/test_igamma_inva.cpp b/test/test_igamma_inva.cpp index a29ffbdec..41bd1ed30 100644 --- a/test/test_igamma_inva.cpp +++ b/test/test_igamma_inva.cpp @@ -249,7 +249,9 @@ int test_main(int, char* []) { expected_results(); +#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS test_gamma(0.1F, "float"); +#endif test_gamma(0.1, "double"); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS test_gamma(0.1L, "long double"); diff --git a/test/test_laguerre.cpp b/test/test_laguerre.cpp index cdff21128..94557ddbb 100644 --- a/test/test_laguerre.cpp +++ b/test/test_laguerre.cpp @@ -256,7 +256,9 @@ void test_spots(T, const char* t) int test_main(int, char* []) { +#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS test_spots(0.0F, "float"); +#endif test_spots(0.0, "double"); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS test_spots(0.0L, "long double"); @@ -265,7 +267,9 @@ int test_main(int, char* []) expected_results(); +#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS test_laguerre(0.1F, "float"); +#endif test_laguerre(0.1, "double"); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS test_laguerre(0.1L, "long double"); diff --git a/test/test_tgamma_ratio.cpp b/test/test_tgamma_ratio.cpp index 00b9f53d7..9e6fd9db2 100644 --- a/test/test_tgamma_ratio.cpp +++ b/test/test_tgamma_ratio.cpp @@ -203,7 +203,9 @@ int test_main(int, char* []) { expected_results(); +#ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS test_tgamma_ratio(0.1F, "float"); +#endif test_tgamma_ratio(0.1, "double"); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS test_tgamma_ratio(0.1L, "long double"); diff --git a/vc71_fix/Jamfile.v2 b/vc71_fix/Jamfile.v2 new file mode 100644 index 000000000..3ed51cf46 --- /dev/null +++ b/vc71_fix/Jamfile.v2 @@ -0,0 +1,6 @@ +# Copyright 2007 John Maddock and Paul A. Bristow. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +lib vc_fix : instantiate_all.cpp : static ; + diff --git a/vc71_fix/instantiate_all.cpp b/vc71_fix/instantiate_all.cpp new file mode 100644 index 000000000..450ca188e --- /dev/null +++ b/vc71_fix/instantiate_all.cpp @@ -0,0 +1,29 @@ +// Copyright John Maddock 2006. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// +// MSVC-7.1 has a problem with our tests: sometimes when a +// function is used via a function pointer, it does *not* +// instantiate the template, leading to unresolved externals +// at link time. Therefore we create a small library that +// instantiates "everything", and link all our tests against +// it for msvc-7.1 only. Note that due to some BBv2 limitations +// we can not place this in a sub-folder of the test directory +// as that would lead to recursive project dependencies... +// + +#include "../test/compile_test/instantiate.hpp" +#include + +void some_proc() +{ + instantiate(float(0)); + instantiate(double(0)); + instantiate(static_cast(0)); + instantiate(static_cast(0)); +} + + +