When compiled in MSVC, dict.c triggers warning C4018 for comparing signed
and unsigned values in two places.

In both cases, the code basically does:

if (pool->end - pool->free > unsigned int) ...

The type of the LHS here is ptrdiff_t, which is signed.  When comparing
signed to unsigned values, the compiler will convert the signed value to an
unsigned value.  So if pool->end < pool->free, the comparison will almost
always succeed, which was probably not the intent.

The attached patch is one conservative way to fix this, which should be
correct in all cases on all platforms.  Another route, if you know that
pool->end >= pool->free in all cases, would be to simply cast to size_t
without additional checks.  Yet another route, if you knew the above AND
that the difference would fit in an unsigned int, would be to
unconditionally cast to unsigned int.

This seems to be the only place preventing Chromium from compiling libxml
with this warning enabled (which is the default state for this warning), so
it would be nice to fix.  The attached patch was generated from an older
copy of the libxml sources, but I think should still apply (possibly with a
slight offset) to the current tree.

PK

Attachment: xml_signedness.patch
Description: Binary data

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml

Reply via email to