Stream: t-lang/wg-unsafe-code-guidelines

Topic: size-of-fn-pointer-versus-data-pointer


nikomatsakis (Aug 24 2018 at 17:19, on Zulip):

So I'm sure that sizeof(void*) (data pointer) and sizeof(void (*)()) (fn pointer) in C are not guaranteed to be the same — does anyone know of any actual architectures where data and function pointers are really different?

Nicole Mazzuca (Aug 24 2018 at 18:03, on Zulip):

16-bit PIC microcontrollers, apparently, and also classic DOS 8086 machines

Nicole Mazzuca (Aug 24 2018 at 18:07, on Zulip):

the POSIX standard apparently only requires that void (*)() be storable in void*

RalfJ (Aug 24 2018 at 18:09, on Zulip):

as in, fn ptrs must be smaller?

RalfJ (Aug 24 2018 at 18:09, on Zulip):

is that the case on this architectures you mentioned?

Nicole Mazzuca (Aug 24 2018 at 18:11, on Zulip):

not on 16-bit pic - SRAM is more expensive than ROM, so data pointers can be smaller, apparently

Nicole Mazzuca (Aug 24 2018 at 18:12, on Zulip):

and the Medium memory model on x86 used 32-bit void()() and 16-bit void

Last update: Nov 20 2019 at 12:30UTC