Article View: comp.std.c++
Article #26Re: implicit pointer of pointer argument promotion legal C++?
From: Scott Meyers
Date: Sun, 01 Nov 1992 20:15
Date: Sun, 01 Nov 1992 20:15
24 lines
1455 bytes
1455 bytes
In article <1992Oct31.213412.356@frumious.uucp> uunet.ca!frumious!pat writes:
| In my understanding, one of the principles of C++ is that any construct
| which has the potential to violate the type system is illegal unless
| an explicit cast is used. So the explicit cast should be required in
| the call to f() - not because the compiler knows there is a problem,
| just because it _doesn't_ know there _isn't_. This is exactly why
| you need an explicit cast to convert a pointer to base class to
| pointer to derived class, but not to cast from derived to base.
However, you don't need an explicit cast to go from a T* to a void*.
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;
Scott
-------------------------------------------------------------------------------
What do you say to a convicted felon in Providence? "Hello, Mr. Mayor."
Technical Details
Message-ID:
<1992Nov1.201547.4661@cs.brown.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!brunix!brunix!sdmReferences:
<1992Oct30.051334.1016@frumious.uucp> <1992Oct31.031431.6863@cs.brown.edu> <1992Oct31.213412.356@frumious.uucp>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: <1992Nov1.201547.4661@cs.brown.edu> Sender: news@cs.brown.edu Organization: Brown University Department of Computer Science References: <1992Oct30.051334.1016@frumious.uucp> <1992Oct31.031431.6863@cs.brown.edu> <1992Oct31.213412.356@frumious.uucp> Date: Sun, 1 Nov 1992 20:15:47 GMT Lines: 24