This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix aliasing violation tst-rec-dlopen


On 15 Dec 2015 15:02, Pedro Alves wrote:
> On 12/15/2015 09:49 AM, Florian Weimer wrote:
> > Some GCC versions warn about this.  It's a clear misuse (presumably to
> > avoid writing down the funny function pointer type), so I propose to fix
> > this, instead of assuming that GCC will do the right thing.
> 
> It's actually the form suggested in the dlopen/dlsym man page's EXAMPLE section:
> 
> ~~~
>            /* Writing: cosine = (double (*)(double)) dlsym(handle, "cos");
>               would seem more natural, but the C99 standard leaves
>               casting from "void *" to a function pointer undefined.
>               The assignment used below is the POSIX.1-2003 (Technical
>               Corrigendum 1) workaround; see the Rationale for the
>               POSIX specification of dlsym(). */
> 
>            *(void **) (&cosine) = dlsym(handle, "cos");
> ~~~
> 
> http://linux.die.net/man/3/dlopen

that site is out of date.  the canonical source does not do this:
http://man7.org/linux/man-pages/man3/dlopen.3.html#EXAMPLE
-mike

Attachment: signature.asc
Description: Digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]