bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

dlsym [was: rationale for closein]


From: Eric Blake
Subject: dlsym [was: rationale for closein]
Date: Tue, 19 Jun 2012 11:43:57 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0

On 06/19/2012 11:19 AM, Rich Felker wrote:

>> POSIX is at liberty to define semantics that are not guaranteed by
>> C99/C11, and dlsym() is one of those situations where POSIX has indeed
>> required more from the compiler (including that function pointers can be
>> cast to void* and back again without ill effects).  As written in
>> http://austingroupbugs.net/view.php?id=74,
>>
>>         Note that conversion from a void * pointer to a function pointer
>>         as in:
>>
>>                 fptr = (int (*)(int))dlsym(handle, "my_function");
>>

> I'm not talking about this; this is actually the correct way to do it.
> But the POSIX documentation for dlsym contains an example:
> 
> *(void **)(&fptr) = dlsym(handle, "my_function");

That documentation was rendered obsolete by
http://austingroupbugs.net/view.php?id=74, which was intentionally
written in part with the aliasing problem in mind.  In other words,
POSIX no longer recommends writing *(void**)(&fptr), and you are
complaining about something that has already been fixed.  When the POSIX
2008 Technical Corrigendum is released (most likely later this year, as
it is already in balloting), bug 74 is one of the bugs fixed in that
corrigendum.

-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org



Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]