Bad overload resolution
Bill Currie
bcurrie@tssc.co.nz
Sun Aug 2 15:31:00 GMT 1998
Using the attached file, gcc gives me the following (incorrect) output:
[bcurrie@nzlc01 ~]
$ gcc -O2 -S oload-bug.cc -v
Reading specs from
/home/users/bcurrie/lib/gcc-lib/hppa1.1-stratus-sysv4/egcs-2.92.00/specs
gcc version egcs-2.92.00 19980715 (gcc2 ss-980609 experimental)
/home/users/bcurrie/lib/gcc-lib/hppa1.1-stratus-sysv4/egcs-2.92.00/cpp
-lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus
-D__GNUC_MINOR__=92 -Dhppa -Dunix -D_FTX -D__hppa__ -D__unix__ -D_FTX
-D__hppa -D__unix -Asystem(unix) -Acpu(hppa) -Amachine(hppa)
-D__EXCEPTIONS -D__OPTIMIZE__ -D_PA_RISC1_1 oload-bug.cc
/var/tmp/cc5MPBB8.ii
GNU CPP version egcs-2.92.00 19980715 (gcc2 ss-980609 experimental)
(hppa)
#include "..." search starts here:
#include <...> search starts here:
/home/users/bcurrie/include/g++
/usr/local/include
/home/users/bcurrie/hppa1.1-stratus-sysv4/include
/home/users/bcurrie/lib/gcc-lib/hppa1.1-stratus-sysv4/egcs-2.92.00/include
/usr/include
End of search list.
/home/users/bcurrie/lib/gcc-lib/hppa1.1-stratus-sysv4/egcs-2.92.00/cc1plus
/var/tmp/cc5MPBB8.ii -quiet -dumpbase oload-bug.cc -O2 -version -o
oload-bug.s
GNU C++ version egcs-2.92.00 19980715 (gcc2 ss-980609 experimental)
(hppa1.1-stratus-sysv4) compiled by GNU C version 2.7.2.1.
oload-bug.cc: In method `foobar::foobar()':
oload-bug.cc:21: warning: assuming & on `foobar::callback()'
oload-bug.cc:21: warning: converting from `void (foobar::*)()' to `void
(*)(void *)'
If I reverse the two callback definitions, everything is fine and the
correct address is passed to `func'.
In the file where I first encountered this problem, I actually got an
error, but that was probably because `func' was overloaded as well, but
reversing the declarations of the callback function fixed it. I also
checked the 19980730 version and had the same problem.
I take it that overloaded function resoltion for taking the address of a
function is not meant to be dependent on the order of definitions. This
has always worked for me before (<=2.7.2.1, first time I tried building
this particular program with egcs).
Bill
--
Leave others their otherness
More information about the Gcc-bugs
mailing list