Article View: comp.std.c++
Article #13Re: implicit pointer of pointer argument promotion legal C++?
From: Scott Meyers
Date: Fri, 30 Oct 1992 02:12
Date: Fri, 30 Oct 1992 02:12
32 lines
1784 bytes
1784 bytes
In article <1992Oct29.195546.1@vax1.bham.ac.uk> mccauleyba@vax1.bham.ac.uk writes:
| There is another point that follows from all this when considering function
| pointers. The current standard does not allow any promotion of function
| pointers but can anyone say definitively if something like...
|
| int strcmp(const char*,const char*);
| int (*p)(char *,char*) = strcmp;
|
| ... could be safely allowed.
|
| I can see no hazard in permitting conversion from (*)(const T*) to (*)(T*)
| but then I hadn't seen the danger of converting T** to const T**.
I've been wondering about a similar question. Is there any danger of
allowing the "usual" conversions of pointers and references in parameter
types of function pointers? Example:
void f( int (*)(const void*, const void*) );
int g(const char*, const char*);
f( g ); // error
f (int (*)(const void*, const void*) g ); // fine
If the usual T* ==> void* conversion were allowed for function pointer
parameters, no cast would be required when calling f with g. Is there a
lurking danger here?
Scott
-------------------------------------------------------------------------------
What do you say to a convicted felon in Providence? "Hello, Mr. Mayor."
Technical Details
Message-ID:
<1992Oct30.021207.3985@cs.brown.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!brunix!brunix!sdmReferences:
<1992Oct22.212802.839@urbana.mcd.mot.com> <23999@alice.att.com> <1992Oct29.195546.1@vax1.bham.ac.uk>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: <1992Oct30.021207.3985@cs.brown.edu> Sender: news@cs.brown.edu Organization: Brown University Department of Computer Science References: <1992Oct22.212802.839@urbana.mcd.mot.com> <23999@alice.att.com> <1992Oct29.195546.1@vax1.bham.ac.uk> Date: Fri, 30 Oct 1992 02:12:07 GMT Lines: 32