This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Calling functions through a pointerI


On 12 October 2017 at 18:09, Toshi Morita via gcc <gcc@gcc.gnu.org> wrote:
> This isn't a GCC question specifically - it's more of a C language question.

And so is off-topic here.

> I'm involved in a discussion involving C language function pointers.
> The other party claims calling functions through a function pointer is "undefined behavior" because it's not specifically mentioned in the C language spec.

That's entirely incorrect. All function calls are through function
pointers, see 6.5.2.2 p1:

"The expression that denotes the called function (92) shall have type
pointer to function
returning void or returning a complete object type other than an array type.

(92)  Most often, this is the result of converting an identifier that
is a function designator."

i.e. in foo(args) the function foo is converted to a function pointer,
and that is the expression that denotes the called function. See
6.3.2.1 p4 as well.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]