Boost logo

Boost :

From: Joel de Guzman (joel_at_[hidden])
Date: 2006-11-13 18:01:36

Steve Nutt wrote:
> I've encountered a bug in the spirit library's numeric parsing. Deep in
> boost::spirit::impl is a template extract_int_base which uses the two
> templates positive_accumulate and negative_accumulate.
> When a new digit is parsed, it is accumulated to the current value by
> multiplying the current value by the radix and adding the new digit.
> Overflow is detected at each stage by comparing the new and old values.
> The overflow logic is flawed. It assumes that when the number overflows
> it becomes a smaller number, which is only true if the radix is a power
> of 2. It also requires that the arithmetic operation does
> over/underflow.
> My proposed fix detects overflow before it happens, fixing the parsing
> of large base 10 numbers, and allowing for non overflowing numeric
> types. The changes are only to the three classes mentioned.

Hi Steve,

Thanks. Could you please send in a patch file?


Joel de Guzman

Boost list run by bdawes at, gregod at, cpdaniel at, john at