Subject: | Cast between incompatible function types from ‘void (*)(PerlInterpreter *, CV *)’ {aka ‘void (*)(struct interpreter *, struct cv *)’} to ‘dbistate_t ** (*)(PerlInterpreter *)’ {aka ‘struct dbistate_st ** (*)(struct interpreter *)’} |
GCC 8.3.1 with Perl 5.28.2 reports these warnings about mismatched pointer type to a dbi state function:
gcc -c -D_REENTRANT -D_GNU_SOURCE -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fwrapv -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g -DVERSION=\"1.642\" -DXS_VERSION=\"1.642\" -fPIC "-I/usr/lib64/perl5/CORE" -W -Wall -Wpointer-arith -Wbad-function-cast -Wno-comment -Wno-sign-compare -Wno-cast-qual -Wmissing-noreturn -Wno-unused-parameter Perl.c
In file included from Perl.xs:7:
Perl.xs: In function ‘dbi_get_state’:
DBIXS.h:498:32: warning: cast between incompatible function types from ‘void (*)(PerlInterpreter *, CV *)’ {aka ‘void (*)(struct interpreter *, struct cv *)’} to ‘dbistate_t ** (*)(PerlInterpreter *)’ {aka ‘struct dbistate_st ** (*)(struct interpreter *)’} [-Wcast-function-type]
dbi_state_lval_p = (_dbi_state_lval_t)CvXSUB(cv); \
^
DBIXS.h:506:27: note: in expansion of macro ‘_DBISTATE_DECLARE_COMMON’
# define DBISTATE_DECLARE _DBISTATE_DECLARE_COMMON
^~~~~~~~~~~~~~~~~~~~~~~~
Perl.xs:13:1: note: in expansion of macro ‘DBISTATE_DECLARE’
DBISTATE_DECLARE;
^~~~~~~~~~~~~~~~
[...]
gcc -c -D_REENTRANT -D_GNU_SOURCE -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fwrapv -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g -DVERSION=\"1.642\" -DXS_VERSION=\"1.642\" -fPIC "-I/usr/lib64/perl5/CORE" -W -Wall -Wpointer-arith -Wbad-function-cast -Wno-comment -Wno-sign-compare -Wno-cast-qual -Wmissing-noreturn -Wno-unused-parameter DBI.c
In file included from /usr/lib64/perl5/CORE/perl.h:5310,
from DBIXS.h:23,
from DBI.xs:13:
DBI.xs: In function ‘boot_DBI’:
DBI.xs:4474:42: warning: cast between incompatible function types from ‘dbistate_t ** (*)(PerlInterpreter *)’ {aka ‘struct dbistate_st ** (*)(struct interpreter *)’} to ‘void (*)(PerlInterpreter *, CV *)’ {aka ‘void (*)(struct interpreter *, struct cv *)’} [-Wcast-function-type]
(void) newXS("DBI::_dbi_state_lval", (XSUBADDR_t)_dbi_state_lval, __FILE__);
^
/usr/lib64/perl5/CORE/embed.h:551:42: note: in definition of macro ‘newXS’
#define newXS(a,b,c) Perl_newXS(aTHX_ a,b,c)
^
This is probably harmless but would be great to fix it (e.g. by casting via (void (*) (void)) as documented in GCC manual).