public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* implicit conversion from "pointer to function" to "void*"
@ 1999-07-14  5:11 Klaus Bergdolt
  1999-07-31 23:33 ` Martin v. Loewis
  0 siblings, 1 reply; 2+ messages in thread
From: Klaus Bergdolt @ 1999-07-14  5:11 UTC (permalink / raw)
  To: egcs-bugs

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
----------------------------------------------------------------------




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: implicit conversion from "pointer to function" to "void*"
  1999-07-14  5:11 implicit conversion from "pointer to function" to "void*" Klaus Bergdolt
@ 1999-07-31 23:33 ` Martin v. Loewis
  0 siblings, 0 replies; 2+ messages in thread
From: Martin v. Loewis @ 1999-07-31 23:33 UTC (permalink / raw)
  To: Klaus.Bergdolt; +Cc: egcs-bugs

> in C++ it's possible to implicitly convert a pointer to a function
> to void*.

Really? Looking at the C++ standard, I cannot find the place where
this is allowed. I would have expected that in 4.10, [conv.ptr]/2; but
that is explicitly restricted to pointers-to-object.

Regards,
Martin


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-07-31 23:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-14  5:11 implicit conversion from "pointer to function" to "void*" Klaus Bergdolt
1999-07-31 23:33 ` Martin v. Loewis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).