This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
implicit conversion from "pointer to function" to "void*"
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: implicit conversion from "pointer to function" to "void*"
- From: Klaus Bergdolt <Klaus dot Bergdolt at de dot bosch dot com>
- Date: Wed, 14 Jul 1999 14:10:22 +0200
- Organization: BOSCH Telecom GmbH
Hi,
in C++ it's possible to implicitly convert a pointer to a function to void*.
But g++ complains when it comes to overload resolution.
If I feed the following program to g++ (egcs-2.91.60) I get the error report
test.c: In function `void test()':
test.c:21: no matching function for call to `Test::Test (int ()(int))'
test.c:5: candidates are: Test::Test(const Test &)
test.c:4: Test::Test(void *)
SUN CC does not complain.
Bye
Klaus
-------------------------------------------------------------------------------------------
test program:
struct Test
{
void *p;
Test(void* q) {p=q;}
};
typedef int (*FPTR)(int a);
int Function(int a)
{
return 1;
}
void test()
{
FPTR f = Function;
// a pointer to a function can be assigned to void*
// i.e. it can be implicitly converted to void*
void* p = Function;
// so this should also be possible
Test t(Function);
}
--
----------------------------------------------------------------------
Klaus Bergdolt EMail: Klaus.Bergdolt@de.bosch.com
Bosch Telecom GmbH
Abteilung UC-ON/EUE1
Gerberstr. 33 Phone: (+49 | 0) 7191 13 3198
D-71522 Backnang Fax: (+49 | 0) 7191 13 4320
----------------------------------------------------------------------