------- Comment #6 from jakub at gcc dot gnu dot org 2010-08-15 21:33 ------- There are more possibilities, like: 3) void (*fnptr) (void); void *p = dlsym (...); memcpy (&fnptr, &p, sizeof (p)); fnptr (); The POSIX standard wording doesn't talk about void * and function pointers being compatible types as used in ISO C99, 6.5. It only talks about the same representation and conversion preserving it. Thus, from this wording, I'd say the 1) is also valid for POSIX, but not 2). When the representation is the same, memcpy should be safe, both from aliasing POV and should DTRT, as workaround for the warning in 1).
-- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45289