GNOME Bugzilla – Bug 788312
Compiler warnings concerning signed and unsigned variables
Last modified: 2019-01-30 11:07:53 UTC
Created attachment 360637 [details] [review] Patch for 2.9.5 WHen compiling libxml2 - 2.9.5, I got some compiler warnings concerning signed and unsigned variables as well as warning having to do with typecasts involving "long". The problem is that in Windows, long does does grow to 64-bits like it would in Linux. A fix would be to change the typecasts to intptr_t in stdint. I also tried to fix some some comparisons where signed values were compared with unsigned comparisons. There might also some issues with format and some parameter types also looked at. I did make a patch to try address some of this. There also seems to be issues with fallthrough in case statements that I have not fixed. Please review what I ahve in the patch.
libxml2 must support pre-C99 compilers without stdint.h, so we can't use intptr_t.
I wonder if you can use the autoconf macro — Macro: AC_TYPE_INTPTR_T From: https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Particular-Types.html — Macro: AC_TYPE_INTPTR_T If stdint.h or inttypes.h defines the type intptr_t, define HAVE_INTPTR_T. Otherwise, define intptr_t to a signed integer type wide enough to hold a pointer, if such a type exists. There are some other macros that might also help such as AC_TYPE_UINTPTR_T. The thing is that GCC 7.2.0 and 6.4.0 give warnings about using the long type in Windows for typecasting in Win64 for good reason. The "long" type DOES not grow to 64-bits in Windows. I did the issue with libxslt as well. https://bugzilla.gnome.org/show_bug.cgi?id=788317
The build system for MSVC in win32 doesn't use autoconf, making this complicated. To fix the int-to-pointer casts, I'd suggest to use C89's ptrdiff_t instead of long. It's not guaranteed to be the size of a pointer but I'm not aware of a platform where it isn't. xmlMemFree should simply print the pointer directly with the %p specifier.
Created attachment 360703 [details] [review] Revised patch to address some comments made
I just landed a big set of commits that address various Windows issues. This should make many of the MinGW patches obsolete: https://github.com/Alexpux/MINGW-packages/tree/master/mingw-w64-libxml2 If there are any remaining issues, get in touch with me.
*** Bug 680370 has been marked as a duplicate of this bug. ***