This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR 2719, demangler crash



> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]