This is the mail archive of the gcc-help@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: conversions betwwen function pointers and their calls


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


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