From ca9c8d30bd31cd937ef57a77eb9c131b026a8c1c Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Sun, 13 May 2012 08:15:51 +0000 Subject: [PATCH] =?UTF-8?q?Merge=20from=20trunk:=20*=20Fixes=20ISO=20C++?= =?UTF-8?q?=20does=20not=20support=20the=20=E2=80=98%lg=E2=80=99=20gnu=5Fp?= =?UTF-8?q?rintf=20format=20(refs=20#6852)=20*=20explicit-failures-markup?= =?UTF-8?q?=20merge=20from=20trunk=20*=20supress=20warnings=20in=20implici?= =?UTF-8?q?t=5Fcast.cpp=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [SVN r78450] --- include/boost/lexical_cast.hpp | 12 ++++++++---- test/implicit_cast.cpp | 6 ++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index fb76d29..c2580ec 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -1322,7 +1322,8 @@ namespace boost { { using namespace std; if (put_inf_nan(begin, end, val)) return true; end = begin; - end += sprintf(begin,"%.*g", static_cast(boost::detail::lcast_get_precision()), val); + const double val_as_double = val; + end += sprintf(begin,"%.*g", static_cast(boost::detail::lcast_get_precision()), val_as_double); return end > begin; } @@ -1330,7 +1331,7 @@ namespace boost { { using namespace std; if (put_inf_nan(begin, end, val)) return true; end = begin; - end += sprintf(begin,"%.*lg", static_cast(boost::detail::lcast_get_precision()), val); + end += sprintf(begin,"%.*g", static_cast(boost::detail::lcast_get_precision()), val); return end > begin; } @@ -1353,8 +1354,11 @@ namespace boost { static bool shl_real_type(float val, wchar_t* begin, wchar_t*& end) { using namespace std; if (put_inf_nan(begin, end, val)) return true; + const double val_as_double = val; end = begin + swprintf(begin, end-begin, - L"%.*g", static_cast(boost::detail::lcast_get_precision()), val ); + L"%.*g", + static_cast(boost::detail::lcast_get_precision()), + val_as_double ); return end > begin; } @@ -1362,7 +1366,7 @@ namespace boost { { using namespace std; if (put_inf_nan(begin, end, val)) return true; end = begin + swprintf(begin, end-begin, - L"%.*lg", static_cast(boost::detail::lcast_get_precision()), val ); + L"%.*g", static_cast(boost::detail::lcast_get_precision()), val ); return end > begin; } diff --git a/test/implicit_cast.cpp b/test/implicit_cast.cpp index e18e17a..8c3bc52 100644 --- a/test/implicit_cast.cpp +++ b/test/implicit_cast.cpp @@ -28,5 +28,11 @@ int main() type f = check_return(boost::implicit_cast("hello")); type z = check_return(boost::implicit_cast(foo("hello"))); + + // warning supression: + (void)x; + (void)f; + (void)z; + return boost::report_errors(); }