[PATCH] PR 2719, demangler crash

DJ Delorie dj@redhat.com
Wed Dec 12 15:17:00 GMT 2001


> which I suspect should say:
> 
>   if ((count % 10) != 0 || count < 0)

The extra logic isn't needed.  We just multiplied by 10; any negative
result *must* be non-modulo 10.  And overflow may create a positive
result depending on the bit patterns, so testing for negative isn't
going to help anyway.

> Even better would be to say:
> 
>   if (INTMAX / 10 < count)
> 
> before the:
> 
>   count *= 10

Yeah, that would be better.  A similar test could be used for the
final digit, although it would be slightly more complicated, and the
negative test handles all the possible cases anyway.

But the existing tests should work fine for any base-2 computer.



More information about the Gcc-patches mailing list