Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#908 Optimization causing CCE

Michael Kay
Michael Kay

Saxon decides statically how to evaluate a variable based on the nature of the select expression (or initializing expression). If the select expression is subsequently rewritten by the optimizer, it should reevaluate this decision, but it is not doing so. If the evaluation strategy chosen is not suitable for the rewritten expression, this may cause a failure at runtime. In particular, one rarely-used evaluation strategy is "shared append expression", and is used when the select expression appends an item to a sequence. This strategy is designed to reduce the need for copying of a sequence in the case of a recursive function or template that appends one item to a sequence on each recursive call; however, it may also be used where this is not the case. In such cases, if the select expression is changed by the optimizer from its original form, a ClassCastException occurs at runtime.

A patch to module GeneralVariable is being placed in Subversion on the 9.1 branch. Test case bug84 added.


  • Michael Kay
    Michael Kay

    Fixed in

  • Michael Kay
    Michael Kay

    A further occurrence of this problem has been found in It occurs when the append expression (an expression using the comma operator) appears as an argument to a function call, and is subsequently rewritten as a reference to a global variable because the value of the argument has no dependencies on local data. Rather than patch this case to recompute the evaluation strategy, a patch is being applied to module ExpressionTool whose effect is to detect when "shared append" evaluation is being used inappropriately, and substitute a different evaluation strategy at run-time.