[PATCH] Fix aliasing violation tst-rec-dlopen
Mike Frysinger
vapier@gentoo.org
Tue Dec 15 15:04:00 GMT 2015
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20151215/52147555/attachment.sig>
More information about the Libc-alpha
mailing list