Is a pointer to function pointer convertible to a void pointer and vice versa?

97 views Asked by At
void f(void);
void (*pf)(void) = f;
void *p = &pf;
(*(void (**)(void))p)();

I tried to find the part in the C standard (draft) document that states about such conversion. But I failed to do so in my last 30 minutes.

How is the conversion between a void pointer and a pointer to function pointer defined?

1

There are 1 answers

0
T.C. On BEST ANSWER

§6.3.2.3/p1:

A pointer to void may be converted to or from a pointer to any object type.

§6.2.5/p20:

A pointer type may be derived from a function type or an object type, called the referenced type. [...] A pointer type is a complete object type.

"pointer to function" is an object type, so "pointer to pointer to function" is a pointer to an object type, and so is convertible to and from "pointer to void" by §6.3.2.3/p1.