Wojtek Lerch <wojtek@xxxxxx> 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@xxxxxx>
The Open Group, Thames Tower, Station Road, Reading, RG1 1LX, England
|