Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
L
libxml2
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 69
    • Issues 69
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 9
    • Merge Requests 9
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • GNOME
  • libxml2
  • Issues
  • #79

Closed
Open
Opened Jul 31, 2019 by Daniel Richard G.@iskunk

xmlXPathCeilingFunction() returns incorrect result on AIX due to buggy ceil() function

AIX, even in its latest iterations, has a buggy ceil() function that does not handle negative-zero correctly. On this platform, ceil(-0.1) => 0 (wrong), instead of ceil(-0.1) => -0 (correct). This leads to some test-suite failures:

## XPath expressions regression tests
Result for ./test/XPath/expr/floats failed in result/XPath/expr/floats
File ./test/XPath/expr/floats generated an error

The following patch works around the issue, by explicitly copying the sign of the input:

diff --git a/xpath.c b/xpath.c
index 4734ecc..65a9f09 100644
--- a/xpath.c
+++ b/xpath.c
@@ -9584,7 +9584,12 @@ xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs) {
     CAST_TO_NUMBER;
     CHECK_TYPE(XPATH_NUMBER);
 
+#ifdef _AIX
+    /* Work around buggy ceil() function on AIX */
+    ctxt->value->floatval = copysign(ceil(ctxt->value->floatval), ctxt->value->floatval);
+#else
     ctxt->value->floatval = ceil(ctxt->value->floatval);
+#endif
 }
 
 /**
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: GNOME/libxml2#79