This is the mail archive of the gcc@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]

Re: undefined reference to `__setbits'


grahams wrote:
> You will find it in setbits.c which is part of libchill

Thank you.

> Jeff, It looks to me that it should probably be moved
> into libgcc.c

It refers to other parts of the Chill library (exception
handling, powerset.h), so it should be changed when moved.

Anyway:  Are you sure that this `__setbits()' function works
correctly in Chill?  The following looks like a very obvious bug
for me:

    #define SET_WORD unsigned char
    #define SET_CHAR  unsigned char
    #define SET_SHORT unsigned char

    [...]

    #define SET_WORD_SIZE (sizeof (char) * sizeof (SET_WORD))
    #define SET_SHORT_SIZE (sizeof (char) * sizeof (SET_SHORT))
    #define SET_CHAR_SIZE sizeof (char)

    [...]

    #define SET_BIT_IN_WORD(w,b) ((w) |= 1 << ((SET_WORD_SIZE) - 1 - (b)))
    #define SET_BIT_IN_SHORT(w,b) ((w) |= 1 << ((SET_SHORT_SIZE) - 1 - (b)))
    #define SET_BIT_IN_CHAR(w,b) ((w) |= 1 << ((SET_CHAR_SIZE) - 1 - (b)))

Since `sizeof (unsigned char)' is 1, this `SET_BIT_IN_WORD()'
macro reads in fact

    #define SET_BIT_IN_WORD(w,b) ((w) |= 1 << (- (b)))

which is - sorry - nonsense.

I am now going to implement our own `__setbits()' function for
the Pascal library.  But better document in `expr.c' that the
language-specific library has to provide that function.

    Peter


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