RE: [xml] XPath question w/ libxml2

First of all, I want a better compiler....
I'm afraid you might be seeing some weird floating point troubles.

You have no idea...

Can you try to see if the basic tests from test/XPath/expr/floats
work correctly first ? Then it might be number('NaN') failing or
the index tests.

Ok, I traced things down to xmlXPathEvaluatePredicateResult.
xmlXPathNAN is being initialized properly.  However with this compiler
comparing any value to xmlXPathNAN returns true.  Here's a sample
program to show the strangeness

#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <stdio.h>

void main() {
        xmlXPathObjectPtr obj1,obj2;

        obj1 = xmlXPathNewString("NaN");
        obj1 = xmlXPathConvertNumber(obj1);

        obj2 = xmlXPathNewFloat(1.0);

        fprintf(stdout,"obj1(%f) is equal to obj2(%f) : %d",
                        obj1->floatval, obj2->floatval, 
                   obj1->floatval == obj2->floatval);

And the output:

  Object is a string : NaN
  Object is a number : NaN
  Object is a number : 1
obj1(1.#QNAN0) is equal to obj2(1.000000) : 1

Seems bizarre to me.  The attached patch fixes this specific problem
with msvc, but I wonder where else this might bite.

Attachment: xpath.diff
Description: Binary data

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]