Undefined behaviour causing problems on AVR32
Torbjorn Granlund
tg at gmplib.org
Mon Apr 13 16:11:42 CEST 2009
Bradley Smith <bradsmith at debian.org> writes:
On Mon, 13 Apr 2009 14:02:20 +0200
Torbjorn Granlund <tg at gmplib.org> wrote:
> I agree this is broken in GMP.
>
> I don't fully understand the GMP scanf code.
>
> I find two calls to sscanffuns.c's scan through the ->scan field, both
> from __gmp_doscan. One call uses 3 parameters and the other uses 4
> parameters.
>
> Both the current and your suggested code assumes there are 4 parameters.
> While your code is an improvement, it still looks undefined to me.
>
> Do you agree?
Hmm, yes I didn't spot the call that uses 3 args, I guess a simple way to
fix that would be to change the call that uses 3 args to use 4, by just
putting a dummy argument as the 4th. Maybe not the nicest fix, but I can't
really see an alternative that doesn't involve rewriting large chunks of
the code.
Unfortunately, that might not work either, since the ->scan field might
point at fscanf. (I tried this and got crashes...)
I'll try your initial solution to see if it works in practice.
--
Torbjörn
More information about the gmp-bugs
mailing list