GNOME Bugzilla – Bug 300235
Conversion between void pointer and function pointer in xpath.c
Last modified: 2017-11-27 13:00:40 UTC
Distribution/Version: Debian Here are the warnings I get while building libxml2 2.6.19 with -Wall flag, you might want to fix these, or at least, some. Mike PS: I'm not sure the generated libxml.c file in the python directory matches the one in the tarball, so line numbers might not be accurate. xpath.c: In function `xmlXPathRegisterFuncNS__internal_alias': xpath.c:2834: warning: ISO C forbids passing arg 4 of `xmlHashAddEntry2__internal_alias' between function pointer and `void *' xpath.c: In function `xmlXPathFunctionLookupNS__internal_alias': xpath.c:2915: warning: ISO C forbids assignment between function pointer and `void *' xpath.c: In function `xmlXPathCompOpEval': xpath.c:10434: warning: ISO C forbids assignment between function pointer and `void *' xpath.c:10459: warning: ISO C forbids assignment between function pointer and `void *' c14n.c: In function `xmlC14NIsNodeInNodeset': c14n.c:268: warning: dereferencing type-punned pointer will break strict-aliasing rules testModule.c: In function `main': testModule.c:46: warning: dereferencing type-punned pointer will break strict-aliasing rules libxml.c: In function `libxml_xmlValidCtxtGenericErrorFuncHandler': libxml.c:1739: warning: unused parameter `severity' libxml.c: In function `libxml_xmlValidCtxtGenericWarningFuncHandler': libxml.c:1766: warning: unused parameter `severity' libxml.c: In function `libxml_xmlRelaxNGSetValidErrors': libxml.c:3092: warning: dereferencing type-punned pointer will break strict-aliasing rules libxml.c: In function `libxml_xmlRelaxNGFreeValidCtxt': libxml.c:3138: warning: dereferencing type-punned pointer will break strict-aliasing rules libxml.c: In function `libxml_xmlSchemaSetValidErrors': libxml.c:3256: warning: dereferencing type-punned pointer will break strict-aliasing rules libxml.c: In function `libxml_xmlSchemaFreeValidCtxt': libxml.c:3303: warning: dereferencing type-punned pointer will break strict-aliasing rules Additionnal informations: # gcc -v Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.5/specs Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --enable-__cxa_atexit --with-system-zlib --enable-nls --without-included-gettext --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux Thread model: posix gcc version 3.3.5 (Debian 1:3.3.5-12) tree built using CFLAGS="-Wall -g -O2" ./configure --prefix=/usr
Yeah, we used to have a work around but it broke register aliasing on gcc4 in s390, so it's an open issue again, Daniel
The most correct fix for the "conversion between void pointer and function pointer" warning in xpath.c is to use a union of function and void pointers as payload in hash.c and add separate functions to work with function pointers in hashes. This is a lot of stupid work just for one use case, of course.
Fixed here by ignoring the warnings using GCC pragmas: https://git.gnome.org/browse/libxml2/commit/?id=13acadbb1ca1f42a65c6466dca025d4020be192a