This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Fix aliasing violation tst-rec-dlopen
- From: Pedro Alves <palves at redhat dot com>
- To: Florian Weimer <fweimer at redhat dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Tue, 15 Dec 2015 15:02:21 +0000
- Subject: Re: [PATCH] Fix aliasing violation tst-rec-dlopen
- Authentication-results: sourceware.org; auth=none
- References: <566FE225 dot 8020208 at redhat dot com>
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
Thanks,
Pedro Alves