The constant folder looks for expressions matching various criteria, and if found executes them, replacing that part of the parse tree with the result. So NaN != NaN isn't handled specially.
Dave.
Comment on Re: Clever optimisation: by design or luck?