This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Bugs in numbers.c (with patch)
- To: Guile Mailing List <guile at sourceware dot cygnus dot com>
- Subject: Re: Bugs in numbers.c (with patch)
- From: Dirk Herrmann <dirk at ida dot ing dot tu-bs dot de>
- Date: Thu, 23 Mar 2000 00:18:23 +0100 (MET)
On Wed, 22 Mar 2000, Dirk Herrmann wrote:
> On Wed, 22 Mar 2000, Dale P. Smith wrote:
>
> > SCM is now (void *). So it is unsigned. So (x < 0) will *never*
> > return true. The compiler will probably just optimize away the tests.
> > I would think it would be a good idea to go over all the code and
> > check for places where a raw SCM value is compared < 0.
> >
> > The patch to numbers.h I'm not sure about, but I think it's right.
>
> Thanks for the patches. I have applied them.
As we have learned by now, using void* is by far not sufficient to catch
all misuses of SCM values. The operators ==, !=, <, <=, >, >=, +, -, ++,
-- can be performed on pointers.
Only looking for +, ++, -, --, <, <=, >, >=, !, I compiled guile with SCM
typedef'd to union { struct { scm_bits_t n; } n; }. This resulted in the
following neat little list of suspicious error messages:
continuations.c:136: invalid operands to binary +
eval.c:295: invalid operands to binary +
eval.c:322: invalid operands to binary +
eval.c:326: invalid operands to binary +
eval.c:386: invalid operands to binary +
eval.c:1147: invalid operands to binary +
eval.c:1173: invalid operands to binary +
eval.c:3677: invalid operands to binary +
print.c:358: wrong type argument to unary exclamation mark
struct.c:366: invalid operands to binary +
numbers.c:198: invalid operands to binary >
numbers.c:198: invalid operands to binary <
numbers.c:330: invalid operands to binary <
numbers.c:331: invalid operands to binary >
numbers.c:331: invalid operands to binary <
numbers.c:340: invalid operands to binary >
numbers.c:340: invalid operands to binary <
numbers.c:767: invalid operands to binary <
numbers.c:769: invalid operands to binary <
numbers.c:826: invalid operands to binary <
numbers.c:827: invalid operands to binary <
numbers.c:828: invalid operands to binary <
numbers.c:895: invalid operands to binary <
numbers.c:941: invalid operands to binary <
numbers.c:3733: invalid operands to binary >
numbers.c:3733: invalid operands to binary <
numbers.c:3860: invalid operands to binary >
numbers.c:3860: invalid operands to binary <
numbers.c:3871: invalid operands to binary >
numbers.c:3871: invalid operands to binary <
numbers.c:4278: invalid operands to binary >=
ramap.c:912: invalid operands to binary <
ramap.c:913: invalid operands to binary >=
gc.c:1176: wrong type argument to unary exclamation mark
gc.c:1921: wrong type argument to unary exclamation mark
mallocs.c:75: wrong type argument to unary exclamation mark
There are likely to be more, because I did not look for == and !=, because
they do most of the time correspond of a comparison between to SCM values,
which itself does not indicate a problem - it's just C which does not
allow us to compare unions. The same holds for !=. However, there may be
cases where such a comparison is illegal also.
Best regards
Dirk Herrmann