Pointers to overloaded functions

Bill Currie bcurrie@tssc.co.nz
Mon Aug 3 22:00:00 GMT 1998

This is repost of yesterday's message, reformated (and after trying
again with a more recent egcs) with better indication of what's going

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- 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();

void foobar::callback()

void foobar::callback(void *obj)

[bcurrie@nzlc01 ~]
$ gcc -v
Reading specs from
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 *)'

Leave others their otherness

More information about the Gcc-bugs mailing list