#13 GCC 8 issues 'incompatible function types' warnings

Closed
opened 1 year ago by karen-arutyunov · 0 comments

When building pkgconf 1.5.4 with GCC 8.1.1 on Linux I get the following warnings:

libpkgconf/pkg.c:292:10: warning: cast between incompatible function types from ‘_Bool (*)(pkgconf_pkg_t *, const size_t,  const char *, char *)’ {aka ‘_Bool (*)(struct pkgconf_pkg_ *, const long unsigned int,  const char *, char *)’} to ‘void (*)(void *, const size_t,  const char *, const char *)’ {aka ‘void (*)(void *, const long unsigned int,  const char *, const char *)’} [-Wcast-function-type]
  [':'] = (pkgconf_parser_operand_func_t) pkgconf_pkg_parser_keyword_set,
          ^
libpkgconf/pkg.c:293:10: warning: cast between incompatible function types from ‘_Bool (*)(pkgconf_pkg_t *, const size_t,  const char *, char *)’ {aka ‘_Bool (*)(struct pkgconf_pkg_ *, const long unsigned int,  const char *, char *)’} to ‘void (*)(void *, const size_t,  const char *, const char *)’ {aka ‘void (*)(void *, const long unsigned int,  const char *, const char *)’} [-Wcast-function-type]
  ['='] = (pkgconf_parser_operand_func_t) pkgconf_pkg_parser_value_set
          ^

That's because pkgconf_pkg_parser_keyword_set() and pkgconf_pkg_parser_value_set() functions return bool, while pkgconf_parser_operand_func_t specifies void as a return type.

As I can see these 2 functions are static and are only used in the following initialization:

static const pkgconf_parser_operand_func_t pkg_parser_funcs[256] = {
    [':'] = (pkgconf_parser_operand_func_t) pkgconf_pkg_parser_keyword_set,
    ['='] = (pkgconf_parser_operand_func_t) pkgconf_pkg_parser_value_set
};

Shouldn't they be changed to just return void then?

When building pkgconf 1.5.4 with GCC 8.1.1 on Linux I get the following warnings: ``` libpkgconf/pkg.c:292:10: warning: cast between incompatible function types from ‘_Bool (*)(pkgconf_pkg_t *, const size_t, const char *, char *)’ {aka ‘_Bool (*)(struct pkgconf_pkg_ *, const long unsigned int, const char *, char *)’} to ‘void (*)(void *, const size_t, const char *, const char *)’ {aka ‘void (*)(void *, const long unsigned int, const char *, const char *)’} [-Wcast-function-type] [':'] = (pkgconf_parser_operand_func_t) pkgconf_pkg_parser_keyword_set, ^ libpkgconf/pkg.c:293:10: warning: cast between incompatible function types from ‘_Bool (*)(pkgconf_pkg_t *, const size_t, const char *, char *)’ {aka ‘_Bool (*)(struct pkgconf_pkg_ *, const long unsigned int, const char *, char *)’} to ‘void (*)(void *, const size_t, const char *, const char *)’ {aka ‘void (*)(void *, const long unsigned int, const char *, const char *)’} [-Wcast-function-type] ['='] = (pkgconf_parser_operand_func_t) pkgconf_pkg_parser_value_set ^ ``` That's because pkgconf_pkg_parser_keyword_set() and pkgconf_pkg_parser_value_set() functions return bool, while pkgconf_parser_operand_func_t specifies void as a return type. As I can see these 2 functions are static and are only used in the following initialization: ``` static const pkgconf_parser_operand_func_t pkg_parser_funcs[256] = { [':'] = (pkgconf_parser_operand_func_t) pkgconf_pkg_parser_keyword_set, ['='] = (pkgconf_parser_operand_func_t) pkgconf_pkg_parser_value_set }; ``` Shouldn't they be changed to just return void then?
Sign in to join this conversation.
No Label
No Milestone
No assignee
1 Participants
Loading...
Cancel
Save
There is no content yet.