This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
Re: Problem with div (1.9.0, arm7tdmi)
- To: "Lewin A.R.W. Edwards" <larwe at larwe dot com>
- Subject: Re: Problem with div (1.9.0, arm7tdmi)
- From: Ingo Krabbe <ikrabbe at earthling dot net>
- Date: Tue, 3 Jul 2001 11:09:49 +0200 (CEST)
- cc: <newlib at sources dot redhat dot com>, <gcc-help at gcc dot gnu dot org>
- Reply-To: Ingo Krabbe <i dot krabbe at dokom dot net>
On Mon, 2 Jul 2001, Lewin A.R.W. 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);
Of course it should work, but you should try
y = (div(a,b)).rem;
and
div_t q = div(a,b);
x = q.quot;
y = q.rem;
just to check if the error is produced by using the return value of the
function in one call.
CU INGO