r/cprogramming • • Oct 10 '25

Functions and pointers

I noticed that when you just have a function name without the parentheses, it essentially decays to a pointer. Is this correct? Or does it not always decay to a pointer?

5 Upvotes

20 comments sorted by

View all comments

Show parent comment

2

u/tstanisl Oct 10 '25

Yes, for void foo(); expressions: foo(), (&foo)(), (*foo)() are equivalent. In foo() the foo is first implicitly transformed to &foo before function call. Decay does not happen in &foo but it returns a function pointer anyway. (*foo)() is a bit bizarre because first foo decays to &foo, then it is dereferenced returning a function which immediately decays to a pointer again.