This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


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

Re: Problem with div (1.9.0, arm7tdmi)


Lewin Edwards wrote:

> I have been experiencing a very odd bug in div() from newlib 1.9.0 on an 
> arm7tdmi target (using gcc 2.95.2/cygwin). The manifestation of the bug is 
> that subroutines will spontaneously return out of the middle of the 
> routine, or hang, especially on nested div calls. I eventually tracked down 
> the culprit and have replaced constructs like:
> 
> x = div(a,b).quot;
> with
> x = a/b;
> 
> and y = div(a,b).rem;
> with
> y = a - ((a / b) * b);

I'm not sure what you mean by "nested div calls" - do you force div() to
call itself recursively or something strange?

I'm not an ARM guy, but this sounds like a struct "return by value" problem.
You need to look at the generated assembly and see if the stack space is
being reclaimed before the value is used, or something of the sort.

Toshi


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