sizeof(function pointer)

Tijl Coosemans tijl at coosemans.org
Wed Jun 1 07:45:10 UTC 2011


On Wednesday 01 June 2011 01:07:29 mdf at freebsd.org wrote:
> I am looking into potentially MFC'ing r212367 and related, that adds
> drains to sbufs.  The reason for MFC is that several pieces of new
> code in CURRENT are using the drain functionality and it would make
> MFCing those changes much easier.
> 
> The problem is that r212367 added a pointer to a drain function in the
> sbuf (it replaced a pointer to void).  The C standard doesn't
> guarantee that a void * and a function pointer have the same size,
> though its true on amd64, i386 and I believe PPC.  What I'm wondering
> is, though not guaranteed by the standard, is it *practically* true
> that sizeof(void *) == sizeof(int(*)(void)), such that an MFC won't
> break binary compatibility for any supported architecture?

It's guaranteed by POSIX.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html
Section 2.12.3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 228 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20110601/b76d324f/attachment.pgp


More information about the freebsd-hackers mailing list