Menu

#21 code_gen.c fix (BYTECODE_REDUCE_REF)

open
nobody
bugfix (13)
5
2002-06-24
2002-06-24
Anonymous
No

In LambdaMOO version 1.8.1...

In the file code_gen.c, with BYTECODE_REDUCE_REF
turned on, you should get a warning (depending on
your compiler environment) regarding an invalid
pointer as the fourth arg for qsort on line 1208. I
believe that this is the correct way to implement the
qsort comparison function:

Replace this function (line 1127):

#ifdef BYTECODE_REDUCE_REF
static int
bbd_cmp(int *a, int *b)
{
return *a - *b;
}
#endif /* BYTECODE_REDUCE_REF */

With this:

#ifdef BYTECODE_REDUCE_REF
static int
bbd_cmp(const void *a, const void *b)
{
return *(int **)a - *(int **)b;
}
#endif /* BYTECODE_REDUCE_REF */

Can anyone confirm this?

Discussion

  • Ely Levy

    Ely Levy - 2002-06-30

    Logged In: YES
    user_id=182092

    what compiler did you get these warning on?
    what was the warnings?
    I compiled lambdamoo on many platfroms and never saw
    compiler warning about that.

     
  • Nobody/Anonymous

    Logged In: NO

    I get the warning too... Using gcc in Debian.
    But when I apply this 'patch', I get this, everytime I log on:

    #88:disfunc (this == #2), line 10: Variable not found
    (End of traceback)

    Where #88 is $frand_class.
    The only variable used in that line is 'this'. Very funny...

    I'm not very good at C, but your fix looks bad...
    Actually, it IS bad, because it causes unexpected behaviour.
    I wouldn't recommend using it...

    Goblin@PhantasyWorld

     
  • Goblin

    Goblin - 2006-02-13

    Logged In: YES
    user_id=1436857

    The warning is:

    code_gen.c:1167: warning: passing arg 4 of `qsort' from
    incompatible pointer type

    gcc version 2.95.4 20020320 [FreeBSD]

    I've had it on GNU/Debian aswell...

    Maybe someone can get us a patch that works...

    Goblin

     
  • Goblin

    Goblin - 2006-03-06

    Logged In: YES
    user_id=1436857

    I think the correct line in code_gen.c should be:

    qsort(bbd, n_bbd, sizeof(*bbd), (int(*)(const void *, const
    void *)) bbd_cmp);

    Maybe someone wants to give me some feedback?

    Goblin

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.