id summary reporter owner description type status milestone component version severity resolution keywords cc 10109 Wrong overflow checking with uint_parser Giulio Franco Joel de Guzman "Running the following code will produce ""`Parsed -2147483648`"" on the standard output. {{{ #!c++ #include #include #include using namespace boost::spirit::qi; int main() { char const test[] = ""2147483648""; //INT_MAX + 1 char const* begin = test; int n; if ( parse( begin, test + sizeof(test) - 1, uint_parser(), n ) ) { std::cout << ""Parsed "" << n << std::endl; } else { std::cout << ""Parse failed"" << std::endl; } return 0; } }}} Since I'm requesting a `uint_parser`, I assume I should never get a negative value. This is what happens, for instance, with `uint_parser`, which will reject negative values. The issue probably lies in `spirit/home/qi/numeric/numeric_utils.hpp`, where `extract_uint::call` invokes {{{ #!c++ extract_type::parse(first, last, detail::cast_unsigned::call(attr_)) }}} but later `positive_accumulator::add`, will check the overflow condition for the type of its argument (which will be `unsigned int`, due to the previous cast), rather than for the template type `T` of the `extract_uint` struct, which is correctly `int`. The call stack I'm talking about is: `parse -> any_uint_parser::parse -> extract_uint::call -> extract_int::parse -> extract_int::parse_main -> int_extractor::call -> int_extractor::call (with mpl::true_) -> positive_accumulator::add`" Bugs closed To Be Determined spirit Boost Release Branch Problem fixed