Pointers to overloaded functions bug

Bill Currie bcurrie@tssc.co.nz
Wed Aug 12 14:51:00 GMT 1998


Did I get kill-filed?:) (just kidding, judging from Jeff's comments
yesterday, everbody who could answer this was probably busy).

Anyway, could someone please tell me if this *IS* a bug or if it is
`new' defined behaviour (the latter seems daft to me).
----
gcc seems to be miss-resolving pointers to overloaded functions.  If I
reverse the two callback declarations in class foobar, all messages
dissappear, and the correct function is used.  I can't see it being
correct that the function selected is dependent on it's declaration
order; it never has before (this is the first time I tried this with
egcs, only gcc-2.7.2.1 and below and other C++ compilers).

[bcurrie@nzlc01 ~]
$ cat oload-bug.cc
void func(void (*)(void *, void *), void *);
void func(void (*)(void *), void *);
void foo(void (*)(void *), void *);

class foobar {
    static void callback(void *);
    void callback();
  public:
    foobar();
};

void foobar::callback()
{
}

void foobar::callback(void *obj)
{
    ((foobar*)obj)->callback();
}

foobar::foobar()
{
    func(callback,this);
    foo(callback,this);
}
[bcurrie@nzlc01 ~]
$ gcc -v
Reading specs from
/home/users/bcurrie/lib/gcc-lib/hppa1.1-stratus-sysv4/egcs-2.91.52/specs
gcc version egcs-2.91.52 19980802 (gcc2 ss-980609 experimental)
[bcurrie@nzlc01 ~]
$ gcc -Wall -Werror -O2 -S oload-bug.cc 
oload-bug.cc: In method `foobar::foobar()':
oload-bug.cc:23: no matching function for call to `func (void
(foobar::)(), foobar *)'
oload-bug.cc:1: candidates are: func(void (*)(void *, void *), void *)
oload-bug.cc:2:                 func(void (*)(void *), void *)
cc1plus: warnings being treated as errors
oload-bug.cc:24: warning: assuming & on `foobar::callback()'
oload-bug.cc:24: warning: converting from `void (foobar::*)()' to `void
(*)(void *)'

Bill
-- 
Leave others their otherness



More information about the Gcc-bugs mailing list