🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #17

Re: implicit pointer of pointer argument promotion legal C++?

#17
From: mccauleyba
Date: Fri, 30 Oct 1992 18:43
40 lines
2310 bytes
In article <1992Oct30.051334.1016@frumious.uucp>, pat@frumious.uucp (Patrick Smith) writes:
>    void f( int (*)(const char*, const char*) );
>    int g(const void*, const void*);
> 
>    f( g );     // Should this be allowed?
> 
> there might not be any semantic problems.
> 
> However, if the conversion from const char* to const void* involves
> any change to the actual representation of the pointer, then the
> compiler may need to generate a small function to use as the
> actual argument to f().  This function would just convert its
> parameters from const char* to const void* and then call g.

There is a problem with this if g is also a ponter to a function as the
compiler would be required to create such a stub function for invokation of
f() this would mean having function pointers into the *stack*.

    void f( int (*)(const char*, const char*) );
    
    void h(int (*g)(const void*, const void*)) {
      f( g );     // Should this be allowed?
    }

I suppose it's possible that a compiler could even have different
representations for `const char *' and `char *' but I don't think that
many compiler writers would start jumping up and down if you told them that
they couldn't.

By the way even if *all* data pointers had the same internal represention this
would not solve the problem as convertion from a pointer to multiply derived 
type, to a pointer to ones of it's base classes will unavoidably sometimes
require an adjustment.

    \\   ( )  NO BULLSHIT! from BAM (Brian McCauley)          
 .  _\\__[oo  ============
.__/  \\ /\@
.  l___\\     E-mail: B.A.McCauley@bham.ac.uk
 # ll  l\\ 
###LL  LL\\
Technical Details
Message-ID: <1992Oct30.184341.1@vax1.bham.ac.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!darwin.sura.net!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!uknet!news.cs.bham.ac.uk!bham!bhamvx!mccauleyba
References: <23999@alice.att.com> <1992Oct29.195546.1@vax1.bham.ac.uk> <1992Oct30.021207.3985@cs.brown.edu> <1992Oct30.051334.1016@frumious.uucp>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!darwin.sura.net!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!uknet!news.cs.bham.ac.uk!bham!bhamvx!mccauleyba
From: mccauleyba@vax1.bham.ac.uk
Newsgroups: comp.std.c++
Subject: Re: implicit pointer of pointer argument promotion legal C++?
Message-ID: <1992Oct30.184341.1@vax1.bham.ac.uk>
Date: 30 Oct 92 18:43:41 GMT
References: <23999@alice.att.com> <1992Oct29.195546.1@vax1.bham.ac.uk> <1992Oct30.021207.3985@cs.brown.edu> <1992Oct30.051334.1016@frumious.uucp>
Sender: usenet@rs6000.bham.ac.uk (USENET News Service)
Organization: University of Birmingham
Lines: 40