This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Calling functions through a pointerI
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Toshi Morita <tm314159 at yahoo dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Thu, 12 Oct 2017 21:47:27 +0100
- Subject: Re: Calling functions through a pointerI
- Authentication-results: sourceware.org; auth=none
- References: <2132674819.640059.1507828186637.ref@mail.yahoo.com> <2132674819.640059.1507828186637@mail.yahoo.com>
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.