Article View: comp.std.c++
Article #44Re: implicit pointer of pointer argument promotion legal C++?
From: Markku Sakkinen
Date: Wed, 04 Nov 1992 10:32
Date: Wed, 04 Nov 1992 10:32
40 lines
2170 bytes
2170 bytes
In article <1992Nov2.193135.6803@cs.brown.edu> sdm@cs.brown.edu (Scott Meyers) writes:
>In article <1d1oirINN3vu@agate.berkeley.edu> jbuck@forney.berkeley.edu (Joe Buck) writes:
>| In article <1992Nov1.201547.4661@cs.brown.edu> sdm@cs.brown.edu (Scott Meyers) writes:
>| >Hence, given that this is legal,
>| > ..
>| >is there a good reason why this isn't?
>| >
>| > void f(T*);
>| > void (*pf)(void*) = f;
>|
>| Certainly. Consider the line that would be legal next:
>|
>| T2* p; // class T2 has no relation to class T
>| pf(p);
>|
>| Now we have passed a pointer to T2 to a function that thinks it is getting
>| a pointer to T, and we have broken the type system.
>
>Boy, either I'm really dense or what we have here is a failure to
>communicate. Clearly (I hope), if pf wants to do anything with its
^^^^^^^^^^^^^^^^^
>argument, it has to know what the real type is, i.e., it's going to have to
>do an explicit cast from void* to whatever the type really is. Obviously
> ...
You _must_ have been day-dreaming a bit.
'pf' is only a pointer, not a function, so it cannot _do_ anything!
The argument is going to the function (i.e., 'f'), not to 'pf'.
'pf(p)' is only shorthand (and obviously often confusing such)
for '(pf*)(p)'.
----------------------------------------------------------------------
Markku Sakkinen (sakkinen@jytko.jyu.fi)
SAKKINEN@FINJYU.bitnet (alternative network address)
Department of Computer Science and Information Systems
University of Jyvaskyla (a's with umlauts)
PL 35
SF-40351 Jyvaskyla (umlauts again)
Finland
----------------------------------------------------------------------
Technical Details
Message-ID:
<1992Nov4.103239.21773@jyu.fi>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!news.funet.fi!network.jyu.fi!sakkinenReferences:
<1992Nov1.201547.4661@cs.brown.edu> <1d1oirINN3vu@agate.berkeley.edu> <1992Nov2.193135.6803@cs.brown.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!news.funet.fi!network.jyu.fi!sakkinen From: sakkinen@jyu.fi (Markku Sakkinen) Subject: Re: implicit pointer of pointer argument promotion legal C++? Message-ID: <1992Nov4.103239.21773@jyu.fi> Organization: University of Jyvaskyla, Finland References: <1992Nov1.201547.4661@cs.brown.edu> <1d1oirINN3vu@agate.berkeley.edu> <1992Nov2.193135.6803@cs.brown.edu> Date: Wed, 4 Nov 1992 10:32:39 GMT Lines: 40