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




--On Wednesday, December 12, 2001 06:12:15 PM -0500 DJ Delorie 
<dj@redhat.com> wrote:

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

Well, then, I don't see how we ever get to having a negative value
for count.  It starts at zero, gets multiplied by 10, and gets
added to.  Oh, I guess it could be just before overflow before the
final digit; good, I didn't see that.

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

It's technically non-conforming though; there's no guarantee about
overflow of signed arithmetic.  On the mainline, this should be fixed
to use INTMAX.

-- 
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com


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