On Mon, 23 Jun 2014 20:48:34 -0400, deadalnix <[email protected]> wrote:

If it will work that way on most plateforms, the other way around
can do VERY nasty things, even on common plateforms like ARM.

Casting to and from a function pointer should not do anything horrific, unless the intermediate type cannot hold the full function pointer.

It is no different than casting from immutable pointer to mutable pointer, and then back to immutable pointer. As long as you don't write to it while it's mutable, it's not illegal.

This is because most CPUs consider the instructions as immutable.
Even x86 do not provide any guarantee (which makes it very hard
to swap implementation outside of a VM).

Remember, these are not functions, but function pointers. You are not modifying the function at all.

Casting from void* to function is pretty guaranteed to be
undefined behavior on all plateforms, unless you emit the proper
barriers.

Can you demonstrate a C example that will fail on ARM?

-Steve

Reply via email to