This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: conversions betwwen function pointers and their calls
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Dima Sorkin <dima dot sorkin at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sun, 28 Sep 2014 16:29:56 -0500
- Subject: Re: conversions betwwen function pointers and their calls
- Authentication-results: sourceware.org; auth=none
- References: <CAMwhkJyZvhqJ9SZa-8N+iwX_yVDX16ev+JKYEUvWwchp1tm+4Q at mail dot gmail dot com>
On Mon, Sep 29, 2014 at 12:06:54AM +0300, Dima Sorkin wrote:
> 1. I have read that the C99 standard allows conversions between
> function pointer types (6.3.2.3 paragraph 8). But if I don't want
> such conversions to appear mistakingly in program - is there any
> command line option to issue a warning?
-Wincompatible-pointer-types, enabled by -Wall.
> 2. Consider the example below, it was compiled by
> GCC 4.9.1 20140903 (prerelease) with
> 'gcc -std=c99 -pedantic -Wall -Wextra'. I don't understand
> why the compiler allows calling of function pointer 'g' of
> type 'void (*)()' with arguments...
Because "f()" does not mean "no arguments"; it means "unspecified
arguments". "f(void)" is "no arguments".
Segher