• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From 3d8a80c4f3470fea0169f6774320e61619bac52b Mon Sep 17 00:00:00 2001
2From: David Tardon <dtardon@redhat.com>
3Date: Mon, 2 Oct 2017 16:22:36 +0200
4Subject: [PATCH] ofz#2894 avoid signed integer overflow
5
6/usr/include/boost/spirit/home/qi/numeric/detail/real_impl.hpp:86:48: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
7---
8 include/boost/spirit/home/qi/numeric/detail/real_impl.hpp | 7 ++++---
9 1 file changed, 4 insertions(+), 3 deletions(-)
10
11diff --git a/include/boost/spirit/home/qi/numeric/detail/real_impl.hpp b/include/boost/spirit/home/qi/numeric/detail/real_impl.hpp
12index 9aa5bb8bb..3e7ab18a9 100644
13--- a/include/boost/spirit/home/qi/numeric/detail/real_impl.hpp
14+++ b/include/boost/spirit/home/qi/numeric/detail/real_impl.hpp
15@@ -81,12 +81,13 @@ namespace boost { namespace spirit { namespace traits
16                 detail::compensate_roundoff(n, acc_n);
17                 n /= pow10<T>(-min_exp);
18
19-                // return false if (-exp + min_exp) exceeds the -min_exp
20+                // return false if exp still exceeds the min_exp
21                 // do this check only for primitive types!
22-                if (is_floating_point<T>() && (-exp + min_exp) > -min_exp)
23+                exp += -min_exp;
24+                if (is_floating_point<T>() && exp < min_exp)
25                     return false;
26
27-                n /= pow10<T>(-exp + min_exp);
28+                n /= pow10<T>(-exp);
29             }
30             else
31             {
32--
332.14.1
34
35