Article View: comp.std.c++
Article #29Re: implicit pointer of pointer argument promotion legal C++?
From: Scott Meyers
Date: Mon, 02 Nov 1992 19:31
Date: Mon, 02 Nov 1992 19:31
32 lines
1786 bytes
1786 bytes
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, | > | > T *p; | > void *q = p; | > | >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 this gives rise to the spector of type errors, but so does any use of void* pointers. So my question is really whether there are any possibilities of type errors other than those inherent in the use of void* pointers. Scott ------------------------------------------------------------------------------- What do you say to a convicted felon in Providence? "Hello, Mr. Mayor."
Technical Details
Message-ID:
<1992Nov2.193135.6803@cs.brown.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!brunix!brunix!sdmReferences:
<1992Oct31.213412.356@frumious.uucp> <1992Nov1.201547.4661@cs.brown.edu> <1d1oirINN3vu@agate.berkeley.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!sparky!uunet!brunix!brunix!sdm From: sdm@cs.brown.edu (Scott Meyers) Subject: Re: implicit pointer of pointer argument promotion legal C++? Message-ID: <1992Nov2.193135.6803@cs.brown.edu> Sender: news@cs.brown.edu Organization: Brown University Department of Computer Science References: <1992Oct31.213412.356@frumious.uucp> <1992Nov1.201547.4661@cs.brown.edu> <1d1oirINN3vu@agate.berkeley.edu> Date: Mon, 2 Nov 1992 19:31:35 GMT Lines: 32