Email List: Xaustin-group-lX
[All Lists]

Re: [1003.1(2008)/Issue 7 0000074]: Pointer Types Problem

To: austin-group-l@xxxxxxxxxxxxx
Subject: Re: [1003.1(2008)/Issue 7 0000074]: Pointer Types Problem
From: Geoff Clare <gwc@xxxxxxxxxxxxx>
Date: Thu, 2 Jul 2009 10:44:04 +0100
References: <e26e5335cda9d0dfe49395e6115066fe@austingroupbugs.net> <1730938080F74546ACC51CB65BA00565@ott.qnx.com>
Wojtek Lerch <wojtek@qnx.com> wrote, on 01 Jul 2009:
>
> > (0000129) msbrown (manager) - 2009-06-29 02:27
> > http://austingroupbugs.net/view.php?id=74#c129
> > --------------------------------------------------------------------
> > After the sentence ending on line 18890, add the following:
> >
> > If a pointer to an object or incomplete type is converted to a
> > pointer to void and then to a pointer to a function type the
> > behavior is undefined.
>
> I don't think this is right. In C, an assignment or an initialization
> is specified to always performs a conversion -- even a conversion from
> a type to the same type is still considered a conversion. Doesn't that
> mean that the value returned by dlsym() cannot be assigned to anything
> without invoking undefined behaviour?

Good point.  I think it needs to say:

    If a pointer to an object or an incomplete type other than void is
    converted ...

> >  If a pointer to a function type is converted to a pointer to
> > void and then to a pointer to an object or an incomplete type the
> > behaviour is undefined.

Likewise this should say "... or an incomplete type other than void ..."

> Doesn't that imply that it's safe to convert a pointer to function
> to a pointer to void, as long as the pointer is not subsequently
> converted to some other pointer type? Is it meant to imply that
> it's OK for a portable POSIX application to take the address of an
> arbitrary function and convert it to void* and back?

That's pretty much exactly what XSH 2.12.3 says, so yes that's the
intention.  Otherwise we would have worded 2.12.3 completely
differently (with explicit reference to dlsym()).

-- 
Geoff Clare <g.clare@opengroup.org>
The Open Group, Thames Tower, Station Road, Reading, RG1 1LX, England

<Prev in Thread] Current Thread [Next in Thread>