Re: null function pointer?
- From: Tim Rentsch <txr@xxxxxxxxxxxxxxxxxxx>
- Date: 12 Oct 2005 16:38:39 -0700
pete <pfiland@xxxxxxxxxxxxxx> writes:
> Tim Rentsch wrote:
> >
> > pete <pfiland@xxxxxxxxxxxxxx> writes:
> >
> > > Chris Torek wrote:
> > > >
> > > > >> Keith Thompson <kst-u@xxxxxxx> writes:
> > > > >> > There is no conversion, explicit or implicit,
> > > > >> > defined between object pointers and function pointers
> > > >
> > > > >Tim Rentsch wrote:
> > > > >> Technically not quite correct. The code
> > > > >>
> > > > >> int (*pf)(void);
> > > > >>
> > > > >> pf = (void*)0;
> > > > >>
> > > > >> converts an object pointer value to a function pointer.
> > > > >> It's true, the object pointer expression in this
> > > > >> case is also a null pointer constant,
> > > > >> but the expression still yields a value of object pointer type,
> > > > >> and that value is converted by the assignment.
> > > >
> > > > In article <434CC4D1.5A1B@xxxxxxxxxxxxxx>
> > > > pete <pfiland@xxxxxxxxxxxxxx> wrote:
> > > > >No.
> > > > >(void *) is a pointer to an incomplete type,
> > > > >not a pointer to an object type.
> > > >
> > > > Indeed, although "pointer to incomplete [data] type" could be
> > > > considered a sub-group of "pointer to object type", or more
> > > > generically, "data pointer" -- to be distinguished from "function
> > > > pointer", a la Harvard architectures in general.
> > >
> > > No.
> > > In C, there's three kinds of types:
> > > 1 object
> > > 2 incomplete
> > > 3 function
> > >
> > > What Keith Thompson wrote is just simply and completely
> > > accurate and useful to know, as far as C is concerned.
> >
> > 1. That presumes it's possible to assign only one meaning to what
> > Keith wrote.
> >
> > 2. It's common usage in ordinary discussions for "object pointer" to
> > mean a pointer to an object type or to an incomplete type. (Not
> > the only usage, but one common usage.) To pretend otherwise is,
> > well, pretending.
>
> I'm not agreeing.
>
> > I don't know which interpretation Keith intended, but certainly
> > more than one interpretation is possible.
>
> The more obvious interpretation is that there's no definition
> for conversions between object addresses and function addresses.
So you agree that more than one interpretation is possible?
Otherwise saying "the more obvious interpretation" seems like it
doesn't make much sense.
> I don't see any point in contradicting his statement.
I wasn't meaning to contradict his statement, only to clarify it.
> As well as not pointing to any object type
> (void *)0 doesn't point to any object.
> "object pointer" doesn't describe (void *)0
> any better than "function pointer" does.
>
> Tthe relationship between
> (void *)0 and pointers to object types,
> is exactly the same as the relationship between
> (void *)0 and pointers to function types.
>
> There's no special relationship between (void *)0
> concerning objects versus functions.
> null pointers are of both pointer to object types
> and pointer to function types.
>
> (void *) is as much of a function pointer
> as it is an object pointer,
> that is to say "it isn't either".
If you want to take the position that "object pointer" never is
heard or intended to mean anything other than (as language in the
Standard would say it) "pointer to object type", I suppose that's
up to you. It does seem counterproductive though to assume that's
what was meant after it was explicitly stated otherwise.
.
- References:
- null function pointer?
- From: Alexei A. Frounze
- Re: null function pointer?
- From: Keith Thompson
- Re: null function pointer?
- From: Tim Rentsch
- Re: null function pointer?
- From: pete
- Re: null function pointer?
- From: pete
- Re: null function pointer?
- From: pete
- null function pointer?
- Prev by Date: Re: Where is the error?
- Next by Date: Re: Where is the error?
- Previous by thread: Re: null function pointer?
- Next by thread: Re: null function pointer?
- Index(es):
Relevant Pages
|