On Mon, 7 Jan 2013, Jakub Jelinek wrote:
Won't the above preclude parsing 2147483640 up to 2147483647 ?
Because then in the last iteration count 214748364 > (INT_MAX - 9) / 10.
You're right -- thanks for catching that! Below is a patch with a more
precise check.
Nickolai.
--- libiberty/cpl
On Sun, Jan 06, 2013 at 11:25:44PM -0500, Nickolai Zeldovich wrote:
> @@ -494,20 +505,15 @@
>
>while (ISDIGIT ((unsigned char)**type))
> {
> - count *= 10;
> -
> - /* Check for overflow.
> - We assume that count is represented using two's-complement;
> - no power of tw
consume_count() in libiberty/cplus-dem.c relies on signed integer overflow
(which is undefined behavior in C) to detect overflow when parsing a count
value. As a result, recent versions of gcc (e.g., 4.7.2) will remove that
if check altogether as dead code, since it can only be true with UB. T